]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Protect against a driver reporting a supply type with a trailing '-'.
authorMichael R Sweet <msweet@msweet.org>
Sun, 5 Apr 2026 13:22:58 +0000 (09:22 -0400)
committerMichael R Sweet <msweet@msweet.org>
Sun, 5 Apr 2026 13:23:02 +0000 (09:23 -0400)
scheduler/printers.c

index 927e85fc50344d342705e0fc1bd0505eefcba7ce..14dae5c7aa927920835f8f7fa75a06ddefb84a0d 100644 (file)
@@ -2198,13 +2198,15 @@ cupsdSetPrinterAttr(
       type  = ippGetString(types, i, NULL);
 
       for (psptr = pstype; *type && psptr < (pstype + sizeof(pstype) - 1); type ++)
-        if (*type == '-')
+      {
+        if (*type == '-' && type[1])
        {
          type ++;
          *psptr++ = (char)toupper(*type & 255);
        }
        else
          *psptr++ = *type;
+      }
       *psptr = '\0';
 
       snprintf(buffer, sizeof(buffer), "index=%d;class=%s;type=%s;unit=percent;maxcapacity=100;level=%d;colorantname=%s;", i + 1, strncmp(pstype, "waste", 5) ? "supplyThatIsConsumed" : "receptacleThatIsFilled", pstype, level, color);