Line
Link Here
|
0 |
-- pinfo-0.6.9-orig/src/filehandling_functions.c |
0 |
++ pinfo-0.6.9/src/filehandling_functions.c |
Lines 96-106
matchfile(char **buf, char *name)
Link Here
|
96 |
{ |
96 |
{ |
97 |
/* use strcat rather than strdup, because xmalloc handles all |
97 |
/* use strcat rather than strdup, because xmalloc handles all |
98 |
* malloc errors */ |
98 |
* malloc errors */ |
99 |
char *thisfile = xmalloc(strlen(dp->d_name)+1); |
99 |
int len = strlen(dp->d_name)+1; |
|
|
100 |
char *thisfile = xmalloc(len * 2); |
101 |
char *thisfile_info = thisfile + len; |
100 |
strcat(thisfile, dp->d_name); |
102 |
strcat(thisfile, dp->d_name); |
101 |
|
103 |
|
102 |
/* strip suffixes (so "gcc.info.gz" -> "gcc") */ |
104 |
/* strip suffixes (so "gcc.info.gz" -> "gcc") */ |
103 |
strip_compression_suffix(thisfile); |
105 |
strip_compression_suffix(thisfile); |
|
|
106 |
strcat(thisfile_info, thisfile); |
104 |
strip_info_suffix(thisfile); |
107 |
strip_info_suffix(thisfile); |
105 |
|
108 |
|
106 |
/* compare this file with the file we're looking for */ |
109 |
/* compare this file with the file we're looking for */ |
Lines 109-116
matchfile(char **buf, char *name)
Link Here
|
109 |
/* we found a match! */ |
112 |
/* we found a match! */ |
110 |
matched++; |
113 |
matched++; |
111 |
/* put it in the buffer */ |
114 |
/* put it in the buffer */ |
112 |
strncat(Buf, thisfile, 1023-strlen(Buf)); |
115 |
strncat(Buf, thisfile_info, 1023-strlen(Buf)); |
113 |
strncat(Buf, ".info", 1023-strlen(Buf)); |
|
|
114 |
|
116 |
|
115 |
/* clean up, and exit the loop */ |
117 |
/* clean up, and exit the loop */ |
116 |
xfree(thisfile); |
118 |
xfree(thisfile); |