Hi,
Gentoo has encountered the same problem:
<http://bugs.gentoo.org/show_bug.cgi?id=306445#c7>

Another related issue is that files beginning with the string "dir"
cannot be opened, e.g. "dired-x" (which is included with emacs):
<http://bugs.gentoo.org/show_bug.cgi?id=340697>

Attached are two patches that should fix these issues. (They are
against pinfo-0.6.9, but can be cleanly applied for 0.6.10 too.)

--- pinfo-0.6.9-orig/src/filehandling_functions.c
+++ pinfo-0.6.9/src/filehandling_functions.c
@@ -96,11 +96,14 @@ matchfile(char **buf, char *name)
        {
                /* use strcat rather than strdup, because xmalloc handles all 
                 * malloc errors */
-               char *thisfile = xmalloc(strlen(dp->d_name)+1);
+               int len = strlen(dp->d_name)+1;
+               char *thisfile = xmalloc(len * 2);
+               char *thisfile_info = thisfile + len;
                strcat(thisfile, dp->d_name);
 
                /* strip suffixes (so "gcc.info.gz" -> "gcc") */
                strip_compression_suffix(thisfile);
+               strcat(thisfile_info, thisfile);
                strip_info_suffix(thisfile);
 
                /* compare this file with the file we're looking for */
@@ -109,8 +112,7 @@ matchfile(char **buf, char *name)
                        /* we found a match! */
                        matched++;
                        /* put it in the buffer */
-                       strncat(Buf, thisfile, 1023-strlen(Buf));
-                       strncat(Buf, ".info", 1023-strlen(Buf));
+                       strncat(Buf, thisfile_info, 1023-strlen(Buf));
 
                        /* clean up, and exit the loop */
                        xfree(thisfile);
--- pinfo-0.6.9-orig/src/filehandling_functions.c
+++ pinfo-0.6.9/src/filehandling_functions.c
@@ -742,7 +742,7 @@
        int i, j;
        char *tmpfilename;
 
-       if (strncmp(filename, "dir", 3) == 0)
+       if (strncmp(filename, "dir", 3) == 0 && !isalnum(filename[3]))
        {
                xfree(buf);
                return opendirfile(number);

Reply via email to