Skip to content

Conversation

@poettering
Copy link
Member

…L parameters

Let's drop the 'static' logic when a parameter can be NULL.

Fixes: #13039

…L parameters

Let's drop the 'static' logic when a parameter can be NULL.

I think asan/ubsan are right here, judging by the C99 spec language:

"A declaration of a parameter as ‘‘array of type’’ shall be adjusted to
‘‘qualified pointer to type’’, where the type qualifiers (if any) are
those specified within the [ and ] of the array type derivation. If the
keyword static also appears within the [ and ] of the array type
derivation, then for each call to the function, the value of the
corresponding actual argument shall provide access to the first element
of an array with at least as many elements as specified by the size
expression."

If we specify NULL, then we certainly don't pvode access to any valid
array.

Fixes: systemd#13039
let's add [static] where it was missing so far

Drop [static] on parameters that can be NULL.

Add an assert() around parameters that have [static] and can't be NULL
hence.

Add some "const" where it was forgotten.
@poettering poettering force-pushed the strip-tab-ansi-no-static-size branch from a5b3601 to 2caa38e Compare July 12, 2019 14:41
@mrc0mmand
Copy link
Member

$ git log --oneline -2
2caa38e99f (HEAD -> pr) tree-wide: some more [static] related fixes
6fb0569065 util-lib: [static] array argument sizes are apparently not OK for NULL parameters
$ build/test-strip-tab-ansi
<        Foobar        bar        waldo        >
<Hello world!>
<something i am a fabulous link something-else>
<something i am a fabulous link something-else>

The issue seems to be gone, thanks!

@yuwata
Copy link
Member

yuwata commented Jul 13, 2019

CI failures are unrelated.

Err:8 http://ftpmaster.internal/ubuntu bionic/universe s390x libpcre2-8-0 s390x 10.31-2
  Could not connect to ftpmaster.internal:80 (91.189.89.99), connection timed out

@yuwata
Copy link
Member

yuwata commented Jul 13, 2019

LGTM.

@yuwata yuwata merged commit 94e0166 into systemd:master Jul 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

AddressSanitizer: SEGV /build/build/../src/basic/string-util.c:732:29 in advance_offset

3 participants