]> granicus.if.org Git - neomutt/commitdiff
Check for int underflow in imap_quote_string
authorJerikoOne <jeriko.one@gmx.us>
Sat, 7 Jul 2018 21:20:56 +0000 (16:20 -0500)
committerRichard Russon <rich@flatcap.org>
Sat, 7 Jul 2018 21:20:56 +0000 (16:20 -0500)
imap/util.c

index 58224fc38725fa30e0bf3579ea24ad43c2e477c5..57802b254dab51b7d3680a1cef494cd65fd68976 100644 (file)
@@ -821,9 +821,9 @@ void imap_quote_string(char *dest, size_t dlen, const char *src, bool quote_back
   {
     if (strchr(quote, *s))
     {
-      dlen -= 2;
-      if (dlen == 0)
+      if (dlen < 2)
         break;
+      dlen -= 2;
       *pt++ = '\\';
       *pt++ = *s;
     }