]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Regression: Locally saved certificates corrupted fix-base-64-encoding 724/head
authorTill Kamppeter <till.kamppeter@gmail.com>
Fri, 9 Jun 2023 21:38:52 +0000 (23:38 +0200)
committerTill Kamppeter <till.kamppeter@gmail.com>
Fri, 9 Jun 2023 21:38:52 +0000 (23:38 +0200)
Base-64-encoding, via the httpEncode64_2() function, used to save
printer/server certificates in files, got broken in commit
a521b235a1ab, ending up with corrupted files not readable when loading
them again and so the certificates of network printers do not get
trusted when a previous copy of them gets loaded from the file. So the
first job prints (no certificate file yet, certificate loaded from
printer) and every subsequent job does not print, as the printer's
certificate does not match the one loaded from the file.

This commit undoes the changes which got applied to the
httpEncode64_2() function to make the certificates correctly encoded
again.

cups/http-support.c

index f92bcba4808a96ae83082a9fbf2b35a306186116..d9c5945ed9582b4dee713726c7cda9800434fc04 100644 (file)
@@ -729,7 +729,7 @@ httpEncode64_2(char       *out,             /* I - String to write to */
       if (inlen > 1)
         *outptr ++ = base64[(((in[0] & 255) << 4) | ((in[1] & 255) >> 4)) & 63];
       else
-        *outptr ++ = base64[(in[0] << 4) & 63];
+        *outptr ++ = base64[((in[0] & 255) << 4) & 63];
     }
 
     in ++;
@@ -746,9 +746,9 @@ httpEncode64_2(char       *out,             /* I - String to write to */
     if (outptr < outend)
     {
       if (inlen > 1)
-        *outptr ++ = base64[((in[0] << 2) | (in[1] >> 6)) & 63];
+        *outptr ++ = base64[(((in[0] & 255) << 2) | ((in[1] & 255) >> 6)) & 63];
       else
-        *outptr ++ = base64[(in[0] << 2) & 63];
+        *outptr ++ = base64[((in[0] & 255) << 2) & 63];
     }
 
     in ++;