]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
ipp.c: fix unreachable else-if block in main()
authorElizaveta Tereshkina <etereshkina@astralinux.ru>
Mon, 1 Sep 2025 15:18:48 +0000 (18:18 +0300)
committerZdenek Dohnal <zdohnal@redhat.com>
Tue, 2 Sep 2025 06:21:13 +0000 (08:21 +0200)
Incorrect if-else structure leads to unreachable code.

When the value of `ipp_status` is equal to `IPP_STATUS_ERROR_INTERNAL`
the variable `waitjob_tries` is incremented and `ippDelete()` function
will be called depending on its value.

In current ipp.c if `ipp_status` is equal to `IPP_STATUS_ERROR_INTERNAL`
it falls into `if` block, because it's not equal to
`IPP_STATUS_ERROR_SERVICE_UNAVAILABLE` and `IPP_STATUS_ERROR_BUSY`.
So `else if` block with `waitjob_tries` is always unreachable
and the function is called unconditionally.

Swap the conditions to correct handling of
`IPP_STATUS_ERROR_INTERNAL` status.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: a469f8a57 (Merge changes from CUPS 1.7svn-r10704.)
Signed-off-by: Elizaveta Tereshkina <etereshkina@astralinux.ru>
backend/ipp.c

index ed157f789084067a7f30dce62ffee57efc1afd21..0bcce69ff0ac6925fa14da5dc0a19f62aede6b96 100644 (file)
@@ -2116,24 +2116,24 @@ main(int  argc,                         /* I - Number of command-line args */
        password_tries = 0;
       else
       {
-       if (ipp_status != IPP_STATUS_ERROR_SERVICE_UNAVAILABLE &&
-           ipp_status != IPP_STATUS_ERROR_BUSY)
-       {
-         ippDelete(response);
+        if (ipp_status == IPP_STATUS_ERROR_INTERNAL)
+        {
+          waitjob_tries ++;
+
+          if (waitjob_tries > 4)
+          {
+            ippDelete(response);
+            ipp_status = IPP_STATUS_OK;
+            break;
+          }
+        }
+        else if (ipp_status != IPP_STATUS_ERROR_SERVICE_UNAVAILABLE &&
+            ipp_status != IPP_STATUS_ERROR_BUSY)
+        {
+          ippDelete(response);
           ipp_status = IPP_STATUS_OK;
           break;
-       }
-       else if (ipp_status == IPP_STATUS_ERROR_INTERNAL)
-       {
-         waitjob_tries ++;
-
-         if (waitjob_tries > 4)
-         {
-           ippDelete(response);
-           ipp_status = IPP_STATUS_OK;
-           break;
-         }
-       }
+        }
       }
 
       if (response)