]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Avoid NULL strcmp argument
authorZdenek Dohnal <zdohnal@redhat.com>
Fri, 14 Mar 2025 06:42:25 +0000 (07:42 +0100)
committerZdenek Dohnal <zdohnal@redhat.com>
Fri, 14 Mar 2025 06:42:25 +0000 (07:42 +0100)
It is possible for format to be NULL (as described in the function signature)
which causes a segmentation fault when it is passed to strcmp. This patch changes
the conditional to short-circuit if format is NULL and only call strcmp otherwise.

backend/ipp.c

index 6888eff5c5d6b684c0d854e7759525482b91ca75..80f5d125819fae8d29d71e71ebd8df252373d52d 100644 (file)
@@ -2984,7 +2984,7 @@ new_request(
       fputs("DEBUG: Adding all operation/job attributes.\n", stderr);
       adjust_options(num_options, options);
 
-      if (!strcmp(format, "image/pwg-raster") || !strcmp(format, "image/urf"))
+      if (format && (!strcmp(format, "image/pwg-raster") || !strcmp(format, "image/urf")))
         num_options = cupsRemoveOption("copies", num_options, &options);
 
       cupsEncodeOptions2(request, num_options, options, IPP_TAG_OPERATION);