Skip to content

Commit

Permalink
[BZ #5424, BZ #5428, BZ #5451]
Browse files Browse the repository at this point in the history
2007-12-08  Ulrich Drepper  <drepper@redhat.com>
	[BZ #5424]
	* stdio-common/vfprintf.c: Do not overflow when adding to done.
	* stdio-common/Makefile (tests): Add bug22.
	* stdio-common/bug22.c: New file.

	[BZ #5451]
	* time/getdate.c: Fix filling in default values.
	* time/bug-getdate1.c: New file.
	* time/Makefile: Add rules to build and run bug-getdate1.

	* iconvdata/ebcdic-is-friss.c: Use 8bit-gap instead of 8bit-generic.
	* iconvdata/ebcdic-es.c: Likewise.
	* iconvdata/ebcdic-es-a.c: Likewise.
	* iconvdata/ebcdic-uk.c: Likewise.
	* iconvdata/iso8859-16.c: Likewise.
	* iconvdata/viscii.c: Likewise.
	* iconvdata/iso8859-9e.c: Likewise.
	* iconvdata/Makefile: Adjust appropriately.

	[BZ #5428]
	* wcsmbs/wchar.h: Unconditionally undefine __need_mbstate and
	__need_wint_t.

	* iconvdata/gconv-modules: Likewise.
  • Loading branch information
Ulrich Drepper committed Dec 10, 2007
1 parent 87520cc commit b4354cf
Show file tree
Hide file tree
Showing 18 changed files with 296 additions and 56 deletions.
26 changes: 26 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
2007-12-08 Ulrich Drepper <drepper@redhat.com>

[BZ #5424]
* stdio-common/vfprintf.c: Do not overflow when adding to done.
* stdio-common/Makefile (tests): Add bug22.
* stdio-common/bug22.c: New file.

[BZ #5451]
* time/getdate.c: Fix filling in default values.
* time/bug-getdate1.c: New file.
* time/Makefile: Add rules to build and run bug-getdate1.

* iconvdata/ebcdic-is-friss.c: Use 8bit-gap instead of 8bit-generic.
* iconvdata/ebcdic-es.c: Likewise.
* iconvdata/ebcdic-es-a.c: Likewise.
* iconvdata/ebcdic-uk.c: Likewise.
* iconvdata/iso8859-16.c: Likewise.
* iconvdata/viscii.c: Likewise.
* iconvdata/iso8859-9e.c: Likewise.
* iconvdata/Makefile: Adjust appropriately.

[BZ #5428]
* wcsmbs/wchar.h: Unconditionally undefine __need_mbstate and
__need_wint_t.

2007-12-07 Ulrich Drepper <drepper@redhat.com>

[BZ #5427]
* iconvdata/hp-roman9.c: New file.
* iconvdata/Makefile: Add rules for hp-roman9.c.
* iconvdata/tst-tables.sh: Add HP-ROMAN9.
* iconvdata/gconv-modules: Likewise.

* iconvdata/hp-roman8.c: Use 8bit-gap instead of 8bit-generic.
* iconvdata/Makefile: Adjust appropriately.
Expand Down
4 changes: 3 additions & 1 deletion NEWS
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
GNU C Library NEWS -- history of user-visible changes. 2007-11-06
GNU C Library NEWS -- history of user-visible changes. 2007-12-07
Copyright (C) 1992-2006, 2007 Free Software Foundation, Inc.
See the end for copying conditions.

Expand All @@ -8,6 +8,8 @@ using `glibc' in the "product" field.
Version 2.8

* New locales: bo_CN, bo_IN.

* New encoding: HP-ROMAN9.

Version 2.7

Expand Down
16 changes: 8 additions & 8 deletions iconvdata/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -217,13 +217,11 @@ install-others = $(addprefix $(inst_gconvdir)/, $(modules.so)) \
# We can build the conversion tables for numerous charsets automatically.

gen-8bit-modules := iso8859-2 iso8859-3 iso8859-4 iso8859-6 iso8859-9 koi-8 \
ebcdic-at-de ebcdic-at-de-a ebcdic-ca-fr \
ebcdic-dk-no ebcdic-dk-no-a ebcdic-es ebcdic-es-a \
ebcdic-es-s ebcdic-fi-se ebcdic-fi-se-a ebcdic-fr \
ebcdic-is-friss ebcdic-it ebcdic-pt ebcdic-uk ebcdic-us \
ebcdic-at-de ebcdic-at-de-a ebcdic-ca-fr ebcdic-dk-no \
ebcdic-dk-no-a ebcdic-es-s ebcdic-fi-se ebcdic-fi-se-a \
ebcdic-fr ebcdic-it ebcdic-pt ebcdic-us \
ibm037 ibm038 ibm274 ibm275 ibm423 ibm500 ibm870 ibm871 \
ibm891 ibm903 ibm904 ibm905 ibm1047 iso8859-16 viscii \
iso8859-9e
ibm891 ibm903 ibm904 ibm905 ibm1047 \

gen-8bit-gap-modules := koi8-r latin-greek latin-greek-1 ibm256 ibm273 \
ibm277 ibm278 ibm280 ibm281 ibm284 ibm285 ibm290 \
Expand All @@ -240,8 +238,10 @@ gen-8bit-gap-modules := koi8-r latin-greek latin-greek-1 ibm256 ibm273 \
iso8859-13 iso8859-14 iso8859-15 mac-uk sami-ws2 \
iso-ir-197 tis-620 koi8-u ibm874 cp10007 koi8-t \
georgian-ps georgian-academy iso-ir-209 mac-sami \
iso8859-11 ibm866nav pt154 rk1048 mik brf \
mac-centraleurope koi8-ru hp-roman8 hp-roman9
iso8859-11 ibm866nav pt154 rk1048 mik brf \
mac-centraleurope koi8-ru hp-roman8 hp-roman9 \
ebcdic-es ebcdic-es-a ebcdic-is-friss ebcdic-uk \
iso8859-16 viscii iso8859-9e

gen-special-modules := iso8859-7jp

Expand Down
8 changes: 4 additions & 4 deletions iconvdata/ebcdic-es-a.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Conversion from and to EBCDIC-ES-A.
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
Expand All @@ -20,10 +20,10 @@

#include <stdint.h>

/* Get the conversion table. */
#include <ebcdic-es-a.h>
/* Specify the conversion table. */
#define TABLES <ebcdic-es-a.h>

#define CHARSET_NAME "EBCDIC-ES-A//"
#define HAS_HOLES 1 /* Not all 256 character are defined. */

#include <8bit-generic.c>
#include <8bit-gap.c>
8 changes: 4 additions & 4 deletions iconvdata/ebcdic-es.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Conversion from and to EBCDIC-ES.
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
Expand All @@ -20,10 +20,10 @@

#include <stdint.h>

/* Get the conversion table. */
#include <ebcdic-es.h>
/* Specify the conversion table. */
#define TABLES <ebcdic-es.h>

#define CHARSET_NAME "EBCDIC-ES//"
#define HAS_HOLES 1 /* Not all 256 character are defined. */

#include <8bit-generic.c>
#include <8bit-gap.c>
8 changes: 4 additions & 4 deletions iconvdata/ebcdic-is-friss.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Conversion from and to EBCDIC-IS-FRISS.
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
Expand All @@ -20,10 +20,10 @@

#include <stdint.h>

/* Get the conversion table. */
#include <ebcdic-is-friss.h>
/* Specify the conversion table. */
#define TABLES <ebcdic-is-friss.h>

#define CHARSET_NAME "EBCDIC-IS-FRISS//"
#define HAS_HOLES 1 /* Not all 256 character are defined. */

#include <8bit-generic.c>
#include <8bit-gap.c>
8 changes: 4 additions & 4 deletions iconvdata/ebcdic-uk.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Conversion from and to EBCDIC-UK.
Copyright (C) 1998 Free Software Foundation, Inc.
Copyright (C) 1998, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1998.
Expand All @@ -20,10 +20,10 @@

#include <stdint.h>

/* Get the conversion table. */
#include <ebcdic-uk.h>
/* Specify the conversion table. */
#define TABLES <ebcdic-uk.h>

#define CHARSET_NAME "EBCDIC-UK//"
#define HAS_HOLES 1 /* Not all 256 character are defined. */

#include <8bit-generic.c>
#include <8bit-gap.c>
7 changes: 7 additions & 0 deletions iconvdata/gconv-modules
Original file line number Diff line number Diff line change
Expand Up @@ -1927,3 +1927,10 @@ alias ISO8859-9E// ISO-8859-9E//
alias ISO88599E// ISO-8859-9E//
module ISO-8859-9E// INTERNAL ISO8859-9E 1
module INTERNAL ISO-8859-9E// ISO8859-9E 1

# from to module cost
alias ROMAN9// HP-ROMAN9//
alias R9// HP-ROMAN9//
alias HPROMAN9// HP-ROMAN9//
module HP-ROMAN9// INTERNAL HP-ROMAN9 1
module INTERNAL HP-ROMAN9// HP-ROMAN9 1
9 changes: 5 additions & 4 deletions iconvdata/iso8859-16.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Conversion from and to ISO 8859-16.
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
Expand All @@ -18,11 +18,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

/* Get the conversion table. */
#include <stdint.h>
#include <iso8859-16.h>

/* Specify the conversion table. */
#define TABLES <iso8859-16.h>

#define CHARSET_NAME "ISO-8859-16//"
#define HAS_HOLES 0 /* All 256 character are defined. */

#include <8bit-generic.c>
#include <8bit-gap.c>
7 changes: 4 additions & 3 deletions iconvdata/iso8859-9e.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

/* Get the conversion table. */
#include <stdint.h>
#include <iso8859-9e.h>

/* Specify the conversion table. */
#define TABLES <iso8859-9e.h>

#define CHARSET_NAME "ISO-8859-9E//"
#define HAS_HOLES 0 /* All 256 character are defined. */

#include <8bit-generic.c>
#include <8bit-gap.c>
9 changes: 5 additions & 4 deletions iconvdata/viscii.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* Conversion from and to VISCII.
Copyright (C) 2000 Free Software Foundation, Inc.
Copyright (C) 2000, 2007 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 2000.
Expand All @@ -18,11 +18,12 @@
Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
02111-1307 USA. */

/* Get the conversion table. */
#include <stdint.h>
#include <viscii.h>

/* Specify the conversion table. */
#define TABLES <viscii.h>

#define CHARSET_NAME "VISCII//"
#define HAS_HOLES 0 /* All 256 character are defined. */

#include <8bit-generic.c>
#include <8bit-gap.c>
2 changes: 1 addition & 1 deletion stdio-common/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ tests := tstscanf test_rdwr test-popen tstgetln test-fseek \
tst-perror tst-sprintf tst-rndseek tst-fdopen tst-fphex bug14 bug15 \
tst-popen tst-unlockedio tst-fmemopen2 tst-put-error tst-fgets \
tst-fwrite bug16 bug17 tst-swscanf tst-sprintf2 bug18 bug18a \
bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21
bug19 bug19a tst-popen2 scanf13 scanf14 scanf15 bug20 bug21 bug22

test-srcs = tst-unbputc tst-printf

Expand Down
32 changes: 32 additions & 0 deletions stdio-common/bug22.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/* BZ #5424 */
#include <stdio.h>

#define N 2147483648

#define STRINGIFY(S) #S
#define MAKE_STR(S) STRINGIFY(S)

#define SN MAKE_STR(N)

static int
do_test (void)
{
int ret;

FILE *fp = fopen ("/dev/null", "w");
if (fp == NULL)
{
puts ("cannot open /dev/null");
return 1;
}

ret = fprintf (fp, "%" SN "d%" SN "d", 1, 1);

printf ("ret = %d\n", ret);

return ret != -1;
}

#define TIMEOUT 30
#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"
32 changes: 23 additions & 9 deletions stdio-common/vfprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@
} while (0)
#define UNBUFFERED_P(S) ((S)->_IO_file_flags & _IO_UNBUFFERED)

#define done_add(val) \
do { \
unsigned int _val = val; \
assert ((unsigned int) done < (unsigned int) INT_MAX); \
if (__builtin_expect ((unsigned int) INT_MAX - (unsigned int) done \
< _val, 0)) \
{ \
done = -1; \
goto all_done; \
} \
done += _val; \
} while (0)

#ifndef COMPILE_WPRINTF
# define vfprintf _IO_vfprintf_internal
# define CHAR_T char
Expand All @@ -76,7 +89,7 @@
# define PUT(F, S, N) _IO_sputn ((F), (S), (N))
# define PAD(Padchar) \
if (width > 0) \
done += INTUSE(_IO_padn) (s, (Padchar), width)
done_add (INTUSE(_IO_padn) (s, (Padchar), width))
# define PUTC(C, F) _IO_putc_unlocked (C, F)
# define ORIENT if (_IO_vtable_offset (s) == 0 && _IO_fwide (s, -1) != -1)\
return -1
Expand All @@ -95,7 +108,7 @@
# define PUT(F, S, N) _IO_sputn ((F), (S), (N))
# define PAD(Padchar) \
if (width > 0) \
done += _IO_wpadn (s, (Padchar), width)
done_add (_IO_wpadn (s, (Padchar), width))
# define PUTC(C, F) _IO_putwc_unlocked (C, F)
# define ORIENT if (_IO_fwide (s, 1) != 1) return -1

Expand All @@ -116,20 +129,21 @@
do \
{ \
register const INT_T outc = (Ch); \
if (PUTC (outc, s) == EOF) \
if (PUTC (outc, s) == EOF || done == INT_MAX) \
{ \
done = -1; \
goto all_done; \
} \
else \
++done; \
++done; \
} \
while (0)

#define outstring(String, Len) \
do \
{ \
if ((size_t) PUT (s, (String), (Len)) != (size_t) (Len)) \
assert ((size_t) done <= (size_t) INT_MAX); \
if ((size_t) PUT (s, (String), (Len)) != (size_t) (Len) \
|| (size_t) INT_MAX - (size_t) done < (size_t) (Len)) \
{ \
done = -1; \
goto all_done; \
Expand Down Expand Up @@ -811,7 +825,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
goto all_done; \
} \
\
done += function_done; \
done_add (function_done); \
} \
break; \
\
Expand Down Expand Up @@ -865,7 +879,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
goto all_done; \
} \
\
done += function_done; \
done_add (function_done); \
} \
break; \
\
Expand Down Expand Up @@ -1893,7 +1907,7 @@ vfprintf (FILE *s, const CHAR_T *format, va_list ap)
goto all_done;
}

done += function_done;
done_add (function_done);
}
break;
}
Expand Down
4 changes: 3 additions & 1 deletion time/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ distribute := datemsk
tests := test_time clocktest tst-posixtz tst-strptime tst_wcsftime \
tst-getdate tst-mktime tst-mktime2 tst-ftime_l tst-strftime \
tst-mktime3 tst-strptime2 bug-asctime bug-asctime_r bug-mktime1 \
tst-strptime3
tst-strptime3 bug-getdate1

include ../Rules

Expand All @@ -56,3 +56,5 @@ test_time-ARGS= EST5EDT CST

tst-strptime-ENV = LOCPATH=${common-objpfx}localedata
tst-ftime_l-ENV = LOCPATH=${common-objpfx}localedata

bug-getdate1-ARGS = ${objpfx}bug-getdate1-fmt
Loading

0 comments on commit b4354cf

Please sign in to comment.