Page MenuHomeFreeBSD

D43990.diff
No OneTemporary

D43990.diff

diff --git a/sbin/md5/md5.c b/sbin/md5/md5.c
--- a/sbin/md5/md5.c
+++ b/sbin/md5/md5.c
@@ -287,9 +287,10 @@
}
struct chksumrec {
- char *filename;
- char *chksum;
- struct chksumrec *next;
+ char *filename;
+ enum input_mode input_mode;
+ char *chksum;
+ struct chksumrec *next;
};
static struct chksumrec *head = NULL;
@@ -362,16 +363,18 @@
if (rec == NULL)
errx(1, "malloc failed");
- if (*filename == '*' ||
- *filename == ' ' ||
- *filename == 'U' ||
- *filename == '^') {
- if (lstat(filename, &st) != 0)
- filename++;
+ if ((*filename == '*' || *filename == ' ' ||
+ *filename == 'U' || *filename == '^') &&
+ lstat(filename, &st) != 0 &&
+ lstat(filename + 1, &st) == 0) {
+ rec->filename = strdup(filename + 1);
+ rec->input_mode = (enum input_mode)*filename;
+ } else {
+ rec->filename = strdup(filename);
+ rec->input_mode = input_mode;
}
rec->chksum = strdup(hashstr);
- rec->filename = strdup(filename);
if (rec->chksum == NULL || rec->filename == NULL)
errx(1, "malloc failed");
rec->next = NULL;
@@ -612,6 +615,13 @@
const char *filename = *argv;
const char *filemode = "rb";
+ if (cflag && mode != mode_bsd) {
+ input_mode = rec->input_mode;
+ checkAgainst = rec->chksum;
+ rec = rec->next;
+ }
+ if (input_mode == input_text)
+ filemode = "r";
if (strcmp(filename, "-") == 0) {
f = stdin;
} else {
@@ -626,14 +636,8 @@
warn("%s", filename);
failed = true;
}
- if (cflag && mode != mode_bsd)
- rec = rec->next;
continue;
}
- if (cflag && mode != mode_bsd) {
- checkAgainst = rec->chksum;
- rec = rec->next;
- }
p = MDInput(&Algorithm[digest], f, buf, false);
if (f != stdin)
(void)fclose(f);

File Metadata

Mime Type
text/plain
Expires
Mon, Apr 28, 1:25 PM (10 h, 47 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
17830366
Default Alt Text
D43990.diff (1 KB)

Event Timeline