From 54652230d4f22f17a00a96493721c0688c838cd0 Mon Sep 17 00:00:00 2001 From: Matt Kraai Date: Wed, 18 Apr 2001 15:51:45 +0000 Subject: [PATCH] Eliminate a segfault when called on an existing file with out an extension: touch foo && gunzip foo --- archival/gunzip.c | 4 ++-- gunzip.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/archival/gunzip.c b/archival/gunzip.c index c3960e953..65f435651 100644 --- a/archival/gunzip.c +++ b/archival/gunzip.c @@ -158,9 +158,9 @@ extern int gunzip_main(int argc, char **argv) delete_old_file = TRUE; extension = strrchr(if_name, '.'); - if (strcmp(extension, ".gz") == 0) { + if (extension && strcmp(extension, ".gz") == 0) { length -= 3; - } else if (strcmp(extension, ".tgz") == 0) { + } else if (extension && strcmp(extension, ".tgz") == 0) { length -= 4; } else { error_msg_and_die("Invalid extension"); diff --git a/gunzip.c b/gunzip.c index c3960e953..65f435651 100644 --- a/gunzip.c +++ b/gunzip.c @@ -158,9 +158,9 @@ extern int gunzip_main(int argc, char **argv) delete_old_file = TRUE; extension = strrchr(if_name, '.'); - if (strcmp(extension, ".gz") == 0) { + if (extension && strcmp(extension, ".gz") == 0) { length -= 3; - } else if (strcmp(extension, ".tgz") == 0) { + } else if (extension && strcmp(extension, ".tgz") == 0) { length -= 4; } else { error_msg_and_die("Invalid extension");