Fix bug #8157 - std_pcap_cache_reload() fails to parse a cups printcap file correctly.
authorJeremy Allison <jra@samba.org>
Fri, 20 May 2011 19:27:02 +0000 (12:27 -0700)
committerJeremy Allison <jra@samba.org>
Fri, 20 May 2011 20:52:23 +0000 (22:52 +0200)
The parsing code made some strange assumptions about what is a printer
name, and what is a comment.

Autobuild-User: Jeremy Allison <jra@samba.org>
Autobuild-Date: Fri May 20 22:52:23 CEST 2011 on sn-devel-104

source3/printing/print_standard.c

index 6a86d84b1e225e5df9f474ce5a1e0dd9fa343773..c4f9c5b7ae3ab47f6a9c7b9f2fc2a2c21460a0eb 100644 (file)
@@ -93,6 +93,10 @@ bool std_pcap_cache_reload(const char *pcap_name)
 
                        has_punctuation = (strchr_m(p, ' ') ||
                                           strchr_m(p, '\t') ||
+                                          strchr_m(p, '"') ||
+                                          strchr_m(p, '\'') ||
+                                          strchr_m(p, ';') ||
+                                          strchr_m(p, ',') ||
                                           strchr_m(p, '(') ||
                                           strchr_m(p, ')'));
 
@@ -101,11 +105,7 @@ bool std_pcap_cache_reload(const char *pcap_name)
                                continue;
                        }
 
-                       if (strlen(p) <= MAXPRINTERLEN &&
-                           strlen(p) > strlen(name) && !has_punctuation) {
-                               if (!*comment) {
-                                       strlcpy(comment, name, sizeof(comment));
-                               }
+                       if (strlen(p) <= MAXPRINTERLEN && *name == '\0' && !has_punctuation) {
                                strlcpy(name, p, sizeof(name));
                                continue;
                        }
@@ -117,9 +117,6 @@ bool std_pcap_cache_reload(const char *pcap_name)
                        }
                }
 
-               comment[60] = 0;
-               name[MAXPRINTERLEN] = 0;
-
                if (*name && !pcap_cache_add(name, comment, NULL)) {
                        x_fclose(pcap_file);
                        return false;