[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#246096: dpkg: [patch] support for DOS-format input in utils/md5sum.c

Package: dpkg
Version: 1.9.21
Severity: minor
Tags: patch woody

The following patch adds support for DOS-format lines in the -c (check)
input to md5sum, and amends the md5sum man page to remove the 'bug'
about there being no --help option (because there is!).

This patch is against the md5sum provided with dpkg 1.9.21 (woody).


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."

-- System Information
Debian Release: 3.0
Architecture: i386
Kernel: Linux harp 2.4.25 #1 Thu Apr 15 12:04:19 WST 2004 i586

Versions of packages dpkg depends on:
ii  libc6                  2.2.5-11.5        GNU C Library: Shared libraries an
ii  libncurses5            5.2.20020112a-7   Shared libraries for terminal hand
ii  libstdc++2.10-glibc2.2 1:2.95.4-11woody1 The GNU stdc++ library

--- md5sum.1.orig	Thu Nov 25 10:25:40 1999
+++ md5sum.1	Tue Apr 27 14:08:26 2004
@@ -30,7 +30,8 @@
 .B -b
 Use binary mode. In unix environment, only difference between this and
-the normal mode is an asterix preceding the filename in the output.
+the normal mode is an asterix preceding the filename in the output. In 
+a DOS environment it will force handling of DOS line endings.
 .B -c
 Check md5sum of all files listed in
@@ -63,13 +64,10 @@
 This manpage is not quite accurate and has formatting inconsistent
 with other manpages.
-.B md5sum
-does not accept standard options like
-.BR --help .
 .B md5sum
 was originally written by Branko Lankester, and modified afterwards by
 Colin Plumb and Ian Jackson (ijackson@gnu.ai.mit.edu). Manual page was
-added by Juho Vuori (javuori@cc.helsinki.fi)
+added by Juho Vuori (javuori@cc.helsinki.fi).
--- md5sum.c.orig	Sun Apr 29 05:22:51 2001
+++ md5sum.c	Tue Apr 27 14:00:13 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.
 #include <stdio.h>
@@ -226,7 +228,15 @@
 	i = strlen(p);
 	if (i < 2 || i > 255)
 		return 0;
-	p[i-1] = '\0';
+	/*
+	 * 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: pgpQw4S9j9jJ_.pgp
Description: PGP signature

Reply to: