]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Don't report an eror if final NUL is at the end of the buffer. Set errno
authorUlrich Drepper <drepper@redhat.com>
Thu, 20 Jan 2000 02:02:40 +0000 (02:02 +0000)
committerUlrich Drepper <drepper@redhat.com>
Thu, 20 Jan 2000 02:02:40 +0000 (02:02 +0000)
correctly if floating-point number would overflow buffer.

stdlib/strfmon.c

index 187e33fe37951138abd065e5341b280a3e039e43..b1a10bfb74e7992ea147376d702e8918b12391e1 100644 (file)
@@ -1,5 +1,5 @@
 /* Formatting a monetary value according to the current locale.
-   Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
+   Copyright (C) 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>
    and Jochen Hein <Jochen.Hein@informatik.TU-Clausthal.de>, 1996.
@@ -464,7 +464,10 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
        }
 
       if (s[maxsize - 1] != '\0')
-       return -1;
+       {
+         __set_errno (E2BIG);
+         return -1;
+       }
 
       dest += done;
 
@@ -520,9 +523,9 @@ __strfmon_l (char *s, size_t maxsize, __locale_t loc, const char *format, ...)
     }
 
   /* Terminate the string.  */
-  out_char ('\0');
+  *dest = '\0';
 
   va_end (ap);
 
-  return dest - s - 1;
+  return dest - s;
 }