Gentoo Archives: gentoo-commits

From: "Peter Volkov (pva)" <pva@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] gentoo-x86 commit in app-misc/fdupes/files: fdupes-1.40-external-md5sum-quotation-1.patch
Date: Sat, 20 Jun 2009 13:55:21
Message-Id: E1MI12N-0004C0-DV@stork.gentoo.org
1 pva 09/06/20 13:55:19
2
3 Added: fdupes-1.40-external-md5sum-quotation-1.patch
4 Log:
5 Fixed another regression cause by md5sum-external USE flag, bug #273597, thank Sven Wehner for detailed report.
6 (Portage version: 2.2_rc33/cvs/Linux i686)
7
8 Revision Changes Path
9 1.1 app-misc/fdupes/files/fdupes-1.40-external-md5sum-quotation-1.patch
10
11 file : http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-misc/fdupes/files/fdupes-1.40-external-md5sum-quotation-1.patch?rev=1.1&view=markup
12 plain: http://sources.gentoo.org/viewcvs.py/gentoo-x86/app-misc/fdupes/files/fdupes-1.40-external-md5sum-quotation-1.patch?rev=1.1&content-type=text/plain
13
14 Index: fdupes-1.40-external-md5sum-quotation-1.patch
15 ===================================================================
16 Source: Peter Volkov <pva@g.o>
17 Upstream: notified (sent email to <adrian2 AT caribe DOT net>
18 Reason: bugs.gentoo.org/237828 comment #1
19 With USE=md5sum-external fails on filenames with spaces in their names.
20
21 Updated on 2009/06/20:
22 * Fixed free due to wrong length of memory allocation bugs.gentoo.org/273597
23 * Now works with filename that have " in name...
24
25 --- fdupes.c 2009-06-20 10:51:31 +0000
26 +++ fdupes.c 2009-06-20 13:38:39 +0000
27 @@ -291,17 +291,48 @@
28 char *getcrcsignature(char *filename)
29 {
30 static char signature[256];
31 + char *backslashedfilename;
32 char *command;
33 char *separator;
34 FILE *result;
35 -
36 - command = (char*) malloc(strlen(filename)+strlen(EXTERNAL_MD5)+2);
37 + int i=0;
38 + int j=0;
39 + int numofquotes=0;
40 +
41 + /* Find number of " in filename */
42 + while ( filename[i] != '\0' ) {
43 + if ( filename[i] == '\"' )
44 + numofquotes++;
45 + i++;
46 + }
47 +
48 + backslashedfilename = (char*) malloc(strlen(filename)+numofquotes+1);
49 + if (backslashedfilename == NULL) {
50 + errormsg("out of memory\n");
51 + exit(1);
52 + }
53 +
54 + /* Put backslash before each " */
55 + i=0;
56 + while ( filename[i] != '\0' ) {
57 + if ( filename[i] == '\"' ) {
58 + backslashedfilename[j]='\\';
59 + j++;
60 + }
61 + backslashedfilename[j]=filename[i];
62 + i++;
63 + j++;
64 + }
65 + backslashedfilename[j]='\0';
66 +
67 + command = (char*) malloc(strlen(backslashedfilename)+strlen(EXTERNAL_MD5)+6);
68 if (command == NULL) {
69 errormsg("out of memory\n");
70 exit(1);
71 }
72
73 - sprintf(command, "%s %s", EXTERNAL_MD5, filename);
74 + /* Qoutation required to works spaces in filenames */
75 + sprintf(command, "%s \"%s\"", EXTERNAL_MD5, backslashedfilename);
76
77 result = popen(command, "r");
78 if (result == NULL) {
79 @@ -309,6 +340,7 @@
80 exit(1);
81 }
82
83 + free(backslashedfilename);
84 free(command);
85
86 if (fgets(signature, 256, result) == NULL) {