OSDN Git Service

* src/header.c (get_header): fixed wrong end mark checking.
authorarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sun, 28 Jul 2002 16:55:38 +0000 (16:55 +0000)
committerarai <arai@6a8cc165-1e22-0410-a132-eb4e3f353aba>
Sun, 28 Jul 2002 16:55:38 +0000 (16:55 +0000)
git-svn-id: svn+ssh://svn.sourceforge.jp/svnroot/lha/lha/trunk@423 6a8cc165-1e22-0410-a132-eb4e3f353aba

src/header.c

index 44c4cc5..4c7e5ed 100644 (file)
@@ -863,24 +863,21 @@ get_header(fp, hdr)
                                        broken archive. */
     char *system_delim = "//";
     int filename_case = NONE;
+    int end_mark;
 
     memset(hdr, 0, sizeof(LzHeader));
 
     setup_get(data);
 
-    switch (fread(data, 1, I_NAME_LENGTH, fp)) {
-    case I_NAME_LENGTH:
-        break;
-    case 0:
-        return FALSE;           /* end of file */
-    case 1:
-        if (data[0] == '\0')    /* end mark */
-            return FALSE;
-        /* fall through */
-    default:
-        error("Invalid header (LHarc file ?)");
-        return FALSE;   /* finish */
-    }
+       if ((end_mark = getc(fp)) == EOF || end_mark == 0) {
+               return FALSE;   /* finish */
+       }
+    data[0] = end_mark;
+
+    if (fread(data + 1, I_NAME_LENGTH - 1, 1, fp) == 0) {
+               error("Invalid header (LHarc file ?)");
+               return FALSE;   /* finish */
+       }
 
     switch (data[I_HEADER_LEVEL]) {
     case 0: