Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OLSR: Fix invalid-pointer-pair AddressSanitizer errors #1271

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

fxlb
Copy link
Member

@fxlb fxlb commented Jan 4, 2025

Avoid adding a length value to a pointer. The result could be located
in an invalid (freed) region or could give a wild pointer.

The errors were:
1)
    olsr-oobr-1                             : TEST FAILED[...]

reading from file tests/olsr-oobr-1.pcap, link-type EN10MB (Ethernet),
  snapshot length 61
=================================================================
==ERROR: AddressSanitizer: invalid-pointer-pair: 0x60600000004e
  0x606000000852
    #0 0x555555c32d61 in olsr_print [...]/print-olsr.c:346:17

0x60600000004e is located 46 bytes inside of 61-byte region
  [0x606000000020,0x60600000005d)
allocated by thread T0 here:
    #0 0x5555558d18ee in malloc ([...]/tcpdump+0x37d8ee)
    #1 0x555555cf37dc in pcap_check_header [...]/sf-pcap.c:480:14

0x606000000852 is located 1938 bytes after 64-byte region
  [0x606000000080,0x6060000000c0)
freed by thread T0 here:
    #0 0x5555558d1646 in __interceptor_free ([...]/tcpdump+0x37d646)
    #1 0x555555cd3144 in pcap_compile [...]/gencode.c:1009:3

previously allocated by thread T0 here:
    #0 0x5555558d18ee in malloc ([...]/tcpdump+0x37d8ee)
    #1 0x555555cf76d0 in pcap_alloc [...]/scanner.c:5588:9
    #2 0x555555cf76d0 in pcap__scan_buffer [...]/scanner.c:5177:24

SUMMARY: AddressSanitizer: invalid-pointer-pair [...]/print-olsr.c:346:17
  in olsr_print

2)
    olsr-oobr-2                             : TEST FAILED[...]

reading from file tests/olsr-oobr-2.pcap, link-type EN10MB (Ethernet),
  snapshot length 81
=================================================================
==ERROR: AddressSanitizer: invalid-pointer-pair: 0x608000000062
  0x60800000156f
    #0 0x555555c32d61 in olsr_print [...]/print-olsr.c:346:17

0x608000000062 is located 66 bytes inside of 81-byte region
  [0x608000000020,0x608000000071)
allocated by thread T0 here:
    #0 0x5555558d18ee in malloc ([...]/tcpdump+0x37d8ee)
    #1 0x555555cf37dc in pcap_check_header [...]/sf-pcap.c:480:14

Address 0x60800000156f is a wild pointer inside of access range of size
  0x000000000001.
SUMMARY: AddressSanitizer: invalid-pointer-pair [...]/print-olsr.c:346:17
  in olsr_print

Avoid adding a length value to a pointer. The result could be located
in an invalid (freed) region or could give a wild pointer.

The errors were:
1)
    olsr-oobr-1                             : TEST FAILED[...]

reading from file tests/olsr-oobr-1.pcap, link-type EN10MB (Ethernet),
  snapshot length 61
=================================================================
==ERROR: AddressSanitizer: invalid-pointer-pair: 0x60600000004e
  0x606000000852
    #0 0x555555c32d61 in olsr_print [...]/print-olsr.c:346:17

0x60600000004e is located 46 bytes inside of 61-byte region
  [0x606000000020,0x60600000005d)
allocated by thread T0 here:
    #0 0x5555558d18ee in malloc ([...]/tcpdump+0x37d8ee)
    the-tcpdump-group#1 0x555555cf37dc in pcap_check_header [...]/sf-pcap.c:480:14

0x606000000852 is located 1938 bytes after 64-byte region
  [0x606000000080,0x6060000000c0)
freed by thread T0 here:
    #0 0x5555558d1646 in __interceptor_free ([...]/tcpdump+0x37d646)
    the-tcpdump-group#1 0x555555cd3144 in pcap_compile [...]/gencode.c:1009:3

previously allocated by thread T0 here:
    #0 0x5555558d18ee in malloc ([...]/tcpdump+0x37d8ee)
    the-tcpdump-group#1 0x555555cf76d0 in pcap_alloc [...]/scanner.c:5588:9
    the-tcpdump-group#2 0x555555cf76d0 in pcap__scan_buffer [...]/scanner.c:5177:24

SUMMARY: AddressSanitizer: invalid-pointer-pair [...]/print-olsr.c:346:17
  in olsr_print

2)
    olsr-oobr-2                             : TEST FAILED[...]

reading from file tests/olsr-oobr-2.pcap, link-type EN10MB (Ethernet),
  snapshot length 81
=================================================================
==ERROR: AddressSanitizer: invalid-pointer-pair: 0x608000000062
  0x60800000156f
    #0 0x555555c32d61 in olsr_print [...]/print-olsr.c:346:17

0x608000000062 is located 66 bytes inside of 81-byte region
  [0x608000000020,0x608000000071)
allocated by thread T0 here:
    #0 0x5555558d18ee in malloc ([...]/tcpdump+0x37d8ee)
    the-tcpdump-group#1 0x555555cf37dc in pcap_check_header [...]/sf-pcap.c:480:14

Address 0x60800000156f is a wild pointer inside of access range of size
  0x000000000001.
SUMMARY: AddressSanitizer: invalid-pointer-pair [...]/print-olsr.c:346:17
  in olsr_print
@fxlb fxlb marked this pull request as draft January 4, 2025 12:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

1 participant