* archival/bunzip2.c (bunzip2_main): Do not remove files if writing to standard
[oweals/busybox.git] / coreutils / md5sum.c
index 72bc08624477b8976e7ed51ac31bc7d27cd75457..83c769ef2304afb82c8057de6e9a13c719a71e8b 100644 (file)
@@ -699,12 +699,12 @@ static int split_3(char *s,
 
   s[i++] = '\0';
 
-  if (s[i] != ' ' && s[i++] != '*')
+  if (s[i] != ' ' && s[i] != '*')
     return FALSE;
 
   /* All characters between the type indicator and end of line are
      significant -- that includes leading and trailing white space.  */
-  *w = &s[i];
+  *w = &s[++i];
 
   if (escaped_filename) {
     /* Translate each `\n' string in the file name to a NEWLINE,
@@ -770,12 +770,10 @@ static int md5_file(const char *filename,
     have_read_stdin = 1;
     fp = stdin;
   } else {
-    fp = fopen(filename, "r");
-    if (fp == NULL) {
-      perror_msg("%s", filename);
+    fp = wfopen(filename, "r");
+    if (fp == NULL)
       return FALSE;
     }
-  }
 
   if (md5_stream(fp, md5_result)) {
     perror_msg("%s", filename);
@@ -807,12 +805,10 @@ static int md5_check(const char *checkfile_name)
     have_read_stdin = 1;
     checkfile_stream = stdin;
   } else {
-    checkfile_stream = fopen(checkfile_name, "r");
-    if (checkfile_stream == NULL) {
-      perror_msg("%s", checkfile_name);
+    checkfile_stream = wfopen(checkfile_name, "r");
+    if (checkfile_stream == NULL)
       return FALSE;
     }
-  }
 
   line_number = 0;