]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/mbalign: fix unsigned integer overflow [AddressSanitizer]
authorSami Kerola <kerolasa@iki.fi>
Fri, 21 Nov 2014 23:11:31 +0000 (23:11 +0000)
committerSami Kerola <kerolasa@iki.fi>
Fri, 19 Dec 2014 09:10:48 +0000 (09:10 +0000)
This error was reported 155 times.

lib/mbsalign.c:322:18: runtime error: unsigned integer overflow: 0 - 1
cannot be represented in type 'size_t' (aka 'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
lib/mbsalign.c

index b307d19f7cb1a13a6607a94f1209deb155d8950f..052fec611a869ceda0735808904fc1a4ca01cf01 100644 (file)
@@ -319,7 +319,7 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
 {
   /* FIXME: Should we pad with "figure space" (\u2007)
      if non ascii data present?  */
-  while (n_spaces-- && (dest < dest_end))
+  for (/* nothing */; n_spaces && (dest < dest_end); n_spaces--)
     *dest++ = ' ';
   *dest = '\0';
   return dest;