From c38ee8cdbb19a3e84b3bb977098e89bd848e1ac1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Ra=C3=BAl=20S=C3=A1nchez=20Siles?= Date: Tue, 4 Aug 2009 14:17:12 -0700 Subject: [PATCH] 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. --- debian/changelog | 7 +++++++ lib/getopt.c | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) 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++; -- 2.43.0