Skip to content

Conversation

@larsewi
Copy link
Owner

@larsewi larsewi commented Jun 12, 2023

This CodeQL query looks for function calls to the LogToSystemlogStructured function where the terminating key-value pair is missing.

This CodeQL query looks for function calls to the
`LogToSystemlogStructured` function where the terminating key-value pair
is missing.

Ticket: CFE-4185
Changelog: None
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
@larsewi larsewi merged commit cd7f7d1 into master Jun 12, 2023
larsewi added a commit that referenced this pull request Jun 26, 2025
Now that we link with libpromises we no longer have to declare this
here.

```
==45622==ERROR: AddressSanitizer: odr-violation (0x55c3e03d9d40):
  [1] size=1024 'VFQNAME' logging_test.c:11:6 in /home/runner/work/core/core/tests/unit/.libs/logging_test
  [2] size=1024 'VFQNAME' cf3globals.c:64:6 in /home/runner/work/core/core/libpromises/.libs/libpromises.so.3
These globals were registered at these points:
  [1]:
    #0 0x7f770c85306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
    #1 0x55c3e03c776f in _sub_I_00099_1 (/home/runner/work/core/core/tests/unit/.libs/logging_test+0x676f) (BuildId: 7031c26309619108a56e4f80219ce2a3f7dc0d53)
    #2 0x7f770b02a303 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2a303) (BuildId: 42c84c92e6f98126b3e2230ebfdead22c235b667)
    cfengine#3 0x55c3e03c67a4 in _start (/home/runner/work/core/core/tests/unit/.libs/logging_test+0x57a4) (BuildId: 7031c26309619108a56e4f80219ce2a3f7dc0d53)

  [2]:
    #0 0x7f770c85306f in __asan_register_globals ../../../../src/libsanitizer/asan/asan_globals.cpp:350
    #1 0x7f770c32b055 in _sub_I_00099_1 (/home/runner/work/core/core/libpromises/.libs/libpromises.so.3+0x12b055) (BuildId: e23104812e7f54cae9a78b25a00d6f00861edf79)
    #2 0x7f770cfe471e  (/lib64/ld-linux-x86-64.so.2+0x571e) (BuildId: 1c8db5f83bba514f8fd5f1fb6d7be975be1bb855)
    cfengine#3 0x7f770cfe4823  (/lib64/ld-linux-x86-64.so.2+0x5823) (BuildId: 1c8db5f83bba514f8fd5f1fb6d7be975be1bb855)
    cfengine#4 0x7f770cffe59f  (/lib64/ld-linux-x86-64.so.2+0x1f59f) (BuildId: 1c8db5f83bba514f8fd5f1fb6d7be975be1bb855)

==45622==HINT: if you don't care about these errors you may set ASAN_OPTIONS=detect_odr_violation=0
SUMMARY: AddressSanitizer: odr-violation: global 'VFQNAME' at logging_test.c:11:6 in /home/runner/work/core/core/tests/unit/.libs/logging_test
==45622==ABORTING
FAIL: logging_test
```

Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
larsewi added a commit that referenced this pull request Dec 11, 2025
```
==25903==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x50200004460f at pc 0x7fa23c10ec86 bp 0x7ffef7339c60 sp 0x7ffef7339408
READ of size 1 at 0x50200004460f thread T0
    #0 0x7fa23c10ec85 in __interceptor_strncmp ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:497
    #1 0x7fa23be8d09b in StringSafeCompareN /tmp/matchpolicy_poc_3369/cfengine-core/libntech/libutils/string_lib.c:254
    #2 0x7fa23be8d10f in StringEqualN /tmp/matchpolicy_poc_3369/cfengine-core/libntech/libutils/string_lib.c:268
    cfengine#3 0x560644d90e30 in MatchPolicy /tmp/matchpolicy_poc_3369/cfengine-core/cf-agent/files_editline.c:1749
 ---snip---
0x50200004460f is located 1 bytes to the left of 4-byte region [0x502000044610,0x502000044614)
allocated by thread T0 here:
 ---snip---
```

Ticket: ENT-13590
Changelog: Title
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
larsewi added a commit that referenced this pull request Dec 15, 2025
```
==25903==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x50200004460f at pc 0x7fa23c10ec86 bp 0x7ffef7339c60 sp 0x7ffef7339408
READ of size 1 at 0x50200004460f thread T0
    #0 0x7fa23c10ec85 in __interceptor_strncmp ../../../../src/libsanitizer/sanitizer_common/sanitizer_common_interceptors.inc:497
    #1 0x7fa23be8d09b in StringSafeCompareN /tmp/matchpolicy_poc_3369/cfengine-core/libntech/libutils/string_lib.c:254
    #2 0x7fa23be8d10f in StringEqualN /tmp/matchpolicy_poc_3369/cfengine-core/libntech/libutils/string_lib.c:268
    cfengine#3 0x560644d90e30 in MatchPolicy /tmp/matchpolicy_poc_3369/cfengine-core/cf-agent/files_editline.c:1749
 ---snip---
0x50200004460f is located 1 bytes to the left of 4-byte region [0x502000044610,0x502000044614)
allocated by thread T0 here:
 ---snip---
```

Ticket: ENT-13590
Changelog: Title
Signed-off-by: Lars Erik Wik <lars.erik.wik@northern.tech>
(cherry picked from commit 3da06b4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants