Package: dpkg Version: 1.10.21 Severity: minor Tags: patch The following patch adds support for DOS-format lines in the -c (check) input to md5sum. This patch is against the md5sum provided with dpkg 1.10.21 (unstable). Andrew. -- Andrew Shugg <andrew@neep.com.au> http://www.neep.com.au/ "Just remember, Mr Fawlty, there's always someone worse off than yourself." "Is there? Well I'd like to meet him. I could do with a good laugh." --- md5sum.c.orig Tue Mar 9 03:03:19 2004 +++ md5sum.c Tue Apr 27 14:48:20 2004 @@ -11,6 +11,8 @@ * Modified Feburary 1995 by Ian Jackson for use with Colin Plumb's md5.c. * Hacked (modified is too nice a word) January 1997 by Galen Hazelwood * to support GNU gettext. + * Additional damage in April 2004 by Andrew Shugg to support MS-DOS style line + * endings on lines read for '-c' (check). * This file is in the public domain. */ @@ -255,9 +257,18 @@ if (i < 2 || i > 255) return 0; - /* Strip the trailing newline, if present */ - if (p[i-1] == '\n') - p[i-1] = '\0'; + /* Strip the trailing newline and/or carriage return, if present */ + if (p[i-1] == '\n') { + /* + * If this is an "MS-DOS" file then the end of line is marked + * by two characters (\r\n) and not just one (\n on Unix, \r on + * Mac OS). + */ + if (p[i-2] == '\r') + p[i-2] = '\0'; + else + p[i-1] = '\0'; + } strcpy(file, p); return rc;
Attachment:
pgp0eTWkknmOw.pgp
Description: PGP signature