Skip to content

Fix SIGSEGV when --null is empty or whitespace-only - #270

Open
vulragrag-star wants to merge 1 commit into
okbob:masterfrom
vulragrag-star:fix/null-empty-optarg-segfault
Open

vulragrag-star wants to merge 1 commit into
okbob:masterfrom
vulragrag-star:fix/null-empty-optarg-segfault

Conversation

@vulragrag-star

Copy link
Copy Markdown

Fix for issue #269.

--null with an empty or whitespace-only value makes trim_quoted_str() return NULL, and sstrndup() then crashes. Guard that case the same way config.c already does (str ? sstrndup(...) : ...) and store an empty nullstr instead.

# before: SIGSEGV
printf 'a\tb\n1\t\n' | ./pspg --tsv --null='' -X

# after: renders table, exit 0
printf 'a\tb\n1\t\n' | ./pspg --tsv --null='' -X
printf 'a\tb\n1\t\n' | ./pspg --tsv --null='   ' -X
./pspg --null='' </dev/null   # "No data", no crash

Also rebuilt with ./configure && make (same as the Linux workflow).

trim_quoted_str() returns NULL for empty/whitespace-only values;
guard before sstrndup like config.c already does.

Fixes: okbob#269
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.

1 participant