diff options
author | Jim Meyering <jim@meyering.net> | 1995-07-20 21:09:57 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 1995-07-20 21:09:57 +0000 |
commit | d58bdcd4fa4a1bdcd52118e99850f32a4ecc2268 (patch) | |
tree | 6be83df61aa62532e7ad65847ed41a297c84395f | |
parent | 1ae54a614050d2895880217ba63b438bf6c1e587 (diff) | |
download | coreutils-d58bdcd4fa4a1bdcd52118e99850f32a4ecc2268.tar.xz |
(split_3): Accept only old format.
Properly handle file names with leading and trailing white space.
-rw-r--r-- | src/md5sum.c | 48 |
1 files changed, 13 insertions, 35 deletions
diff --git a/src/md5sum.c b/src/md5sum.c index a8ad6cb73..1d4fa46d3 100644 --- a/src/md5sum.c +++ b/src/md5sum.c @@ -146,45 +146,23 @@ split_3 (s, u, binary, w) /* The first field has to be the 32-character hexadecimal representation of the message digest. If it not immediately followed by a white space it's an error. */ - if (!ISWHITE (s[i + 32])) + i += 32; + if (!ISWHITE (s[i])) return 1; - i += 32; s[i++] = '\0'; - /* Now we have to look for two possibilities: the line is in the - new format in which case we have the character 'b' or 't' followed - by a white space or we have a ' ' or '*' immediately followed by - the file name. */ - if (ISWHITE (s[i + 1])) - { - if (s[i] != 'b' && s[i] != 't') - return 1; - *binary = s[i] == 'b'; - i += 2; - } - else - { - if (s[i] != ' ' && s[i] != '*') - return 1; - *binary = s[i] == '*'; - ++i; - } - - if (s[i]) - { - *w = &s[i]; - /* Skip past the third token. */ - while (s[i] && !ISWHITE (s[i])) - ++i; - if (s[i]) - s[i++] = '\0'; - /* Allow trailing white space. */ - while (ISWHITE (s[i])) - ++i; - if (!s[i]) - return 0; - } + if (s[i] != ' ' && s[i] != '*') + return 1; + *binary = s[i++] == '*'; + + /* When using the old format, all characters between the type + indicator and end of line are significant -- that includes + leading and trailing white space. */ + *w = &s[i]; + /* So this line is valid as long as there is at least one character + for the filename. */ + return (**w ? 0 : 1); } return 1; } |