Skip to content

Commit 5ca4326

Browse files
committed
fix(infra): strip the ansible.builtin. prefix without strlen on the offset
GCC 13 on x86-64 (-O1, ASan/UBSan, -Werror) rejected an_key's memmove(out, out + bl, strlen(out + bl) + 1) as -Wstringop-overread, a region of size 0; arm64 GCC and clang accept it. The key length is now measured once and the prefix compared with memcmp. Every C file this branch changes compiles warning-free with that GCC. Signed-off-by: Martin Vogel <martin.vogel.tech@gmail.com>
1 parent 9081863 commit 5ca4326

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/pipeline/pass_ansible.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,8 +151,9 @@ static bool an_key(const an_t *a, TSNode pair, char *out, size_t sz) {
151151
return false;
152152
}
153153
size_t bl = sizeof(BUILTIN) - SKIP_ONE;
154-
if (strncmp(out, BUILTIN, bl) == 0) {
155-
memmove(out, out + bl, strlen(out + bl) + SKIP_ONE);
154+
size_t len = strlen(out);
155+
if (len >= bl && memcmp(out, BUILTIN, bl) == 0) {
156+
memmove(out, out + bl, len - bl + SKIP_ONE);
156157
}
157158
return true;
158159
}

0 commit comments

Comments
 (0)