From: Raúl Sánchez Siles Date: Tue, 4 Aug 2009 21:17:12 +0000 (-0700) Subject: Avoid undefined behavior of passing NULL to strcmp X-Git-Url: https://git.cworth.org/git?p=tar;a=commitdiff_plain;h=c38ee8cdbb19a3e84b3bb977098e89bd848e1ac1 Avoid undefined behavior of passing NULL to strcmp Having a blank line in the file passed to the -T option will cause an entry in the argv array to be NULL. To avoid invoking undefined behavior, we take care not to pass these NULL values to strcmp. --- diff --git a/debian/changelog b/debian/changelog index 393a9e1..5d6ecd5 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +tar (1.22-3) UNRELEASED; urgency=low + + * Avoid undefined behavior of passing NULL to strcmp, closes: #411485 + Thanks to Raúl Sánchez Siles for proposing this patch. + + -- Carl Worth Tue, 04 Aug 2009 17:15:20 -0700 + tar (1.22-2) unstable; urgency=low * Add Carl Worth as an uploader. diff --git a/lib/getopt.c b/lib/getopt.c index f1e6d1f..f1c0e1f 100644 --- a/lib/getopt.c +++ b/lib/getopt.c @@ -413,7 +413,7 @@ _getopt_internal_r (int argc, char **argv, const char *optstring, then exchange with previous non-options as if it were an option, then skip everything else like a non-option. */ - if (d->optind != argc && !strcmp (argv[d->optind], "--")) + if (d->optind != argc && argv[d->optind] && !strcmp (argv[d->optind], "--")) { d->optind++;