]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Prevent underflow (unlikely, but possible)
authorMichael Sweet <michael.r.sweet@gmail.com>
Tue, 27 Jun 2017 16:58:10 +0000 (12:58 -0400)
committerMichael Sweet <michael.r.sweet@gmail.com>
Tue, 27 Jun 2017 17:15:37 +0000 (13:15 -0400)
cups/string.c

index 39a787f0ec427f459ad21c19865878186f43b88e..0d4ed0f50e4d54dce0f7fe92d2a78b1c5992d727 100644 (file)
@@ -695,10 +695,11 @@ _cups_strlcat(char       *dst,            /* O - Destination string */
   */
 
   dstlen = strlen(dst);
-  size   -= dstlen + 1;
 
-  if (!size)
-    return (dstlen);           /* No room, return immediately... */
+  if (size < (dstlen + 1))
+    return (dstlen);                   /* No room, return immediately... */
+
+  size -= dstlen + 1;
 
  /*
   * Figure out how much room is needed...