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:36:56 +0000 (12:36 -0700)
committerKarolin Seeger <kseeger@samba.org>
Mon, 23 May 2011 18:45:43 +0000 (20:45 +0200)
The parsing code made some strange assumptions about what is a printer
name, and what is a comment.

source3/printing/pcap.c

index 0d6480ce0159a89e9349be8cafd3a0137de13e54..dbfbac767afb601dbed241a99722eab061c46134 100644 (file)
@@ -209,6 +209,10 @@ void pcap_cache_reload(void (*post_cache_fill_fn)(void))
 
                        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, ')'));
 
@@ -217,8 +221,7 @@ void pcap_cache_reload(void (*post_cache_fill_fn)(void))
                                continue;
                        }
 
-                       if (strlen(p) <= MAXPRINTERLEN &&
-                           strlen(p) > strlen(name) && !has_punctuation) {
+                       if (strlen(p) <= MAXPRINTERLEN && *name == '\0' && !has_punctuation) {
                                if (!*comment) {
                                        strlcpy(comment, name, sizeof(comment));
                                }
@@ -233,9 +236,6 @@ void pcap_cache_reload(void (*post_cache_fill_fn)(void))
                        }
                }
 
-               comment[60] = 0;
-               name[MAXPRINTERLEN] = 0;
-
                if (*name && !pcap_cache_add(name, comment)) {
                        x_fclose(pcap_file);
                        goto done;