Bug 11147 - parse_printcap broken
parse_printcap broken
Status: CLOSED RAWHIDE
Product: Red Hat Linux
Classification: Retired
Component: xfig (Show other bugs)
6.2
i386 Linux
medium Severity high
: ---
: ---
Assigned To: Ngo Than
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2000-05-01 11:59 EDT by Andrew Schretter
Modified: 2008-05-01 11:37 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2000-06-26 15:45:35 EDT
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Andrew Schretter 2000-05-01 11:59:59 EDT
I have already submitted this patch to the xfig maintainer in hopes
that he'll incorporate it there.  The problem is that the parse_printcap
function in w_print.c does not take into account duplicate print entries
(minor problem) and does not discard blank printer names (major problem).
The latter is killer since it takes any blank space at the beginning
of a line as a printer name and there is a hardcoded limit of 200 printers
in the the code.  Even with our 25 printers, appearing twice in the
printcap each, there were 215 that came up and crashed xfig anytime you
tried to print.

Here is the patch to fix it.
--- xfig.3.2.3-beta-1/w_print.c Wed Sep 22 14:56:58 1999
+++ xfig.3.2.3-beta-1.new/w_print.c     Mon May  1 11:36:56 2000
@@ -967,9 +967,10 @@
 {
     FILE   *printcap;
     char    str[300];
-    int     i,j,len;
+    int     i,j,k,len;
     int     printers;
     Boolean comment;
+    Boolean dudprinter;
     if ((printcap=fopen("/etc/printcap","r"))==NULL)
        return 0;
@@ -1002,6 +1003,20 @@
                break;
        }
        str[j] = '\0';
+        /* Check for empty printer name or duplicate name */
+        dudprinter = True;
+        for (k=0; k<j; k++) {
+            if(str[k] !=' ' && str[k] != '\t')
+               dudprinter = False;
+        }
+        if(printers > 0) {
+            for (k=0; k<printers; k++) {
+                if(strncmp(names[k],&str[i],j-i+1) == 0)
+                    dudprinter = True;
+            }
+        }
+        if (dudprinter == True)
+            continue;
        if ((names[printers] = malloc(j-i+1)) == NULL)
            return printers;
        strncpy(names[printers],&str[i],j-i+1);

Andrew
Comment 1 Ngo Than 2000-08-05 09:07:28 EDT
added the patch in xfig-3.2.3c for RC1.

Note You need to log in before you can comment on or make changes to this bug.