Eliminate a segfault when called on an existing file with out an extension:
authorMatt Kraai <kraai@debian.org>
Wed, 18 Apr 2001 15:51:45 +0000 (15:51 -0000)
committerMatt Kraai <kraai@debian.org>
Wed, 18 Apr 2001 15:51:45 +0000 (15:51 -0000)
touch foo && gunzip foo

archival/gunzip.c
gunzip.c

index c3960e953221193bd5cc6fefd7559a6db25a3ae2..65f435651a492440874131dba48a6cb58b125a5a 100644 (file)
@@ -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");
index c3960e953221193bd5cc6fefd7559a6db25a3ae2..65f435651a492440874131dba48a6cb58b125a5a 100644 (file)
--- 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");