[patch:] iconv/gconv.c: Don't refer to parameter cd before testing for validity.
Hans-Peter Nilsson
hans-peter.nilsson@axis.com
Sun Apr 8 18:19:00 GMT 2001
Hi. While working on a glibc port to Linux/CRIS (cris-axis-linux-gnu),
I've stumbled on a few glibc bugs, some by visual inspection and some by
executing code. I'm sending everything as separate patches.
If parameter cd can be (__gconv_t) -1L, then I guess it shouldn't be
accessed before checked.
2001-04-08 Hans-Peter Nilsson <hp@axis.com>
* iconv/gconv.c (__gconv): Don't derefer parameter cd before
checking if == -1L.
Index: gconv.c
===================================================================
RCS file: /cvs/glibc/libc/iconv/gconv.c,v
retrieving revision 1.23
diff -p -c -r1.23 gconv.c
*** gconv.c 2000/11/20 08:48:18 1.23
--- gconv.c 2001/04/08 21:37:37
***************
*** 1,6 ****
/* Convert characters in input buffer using conversion descriptor to
output buffer.
! Copyright (C) 1997, 1998, 1999, 2000 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
--- 1,6 ----
/* Convert characters in input buffer using conversion descriptor to
output buffer.
! Copyright (C) 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
This file is part of the GNU C Library.
Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
*************** __gconv (__gconv_t cd, const unsigned ch
*** 31,41 ****
const unsigned char *inbufend, unsigned char **outbuf,
unsigned char *outbufend, size_t *irreversible)
{
! size_t last_step = cd->__nsteps - 1;
int result;
if (cd == (__gconv_t) -1L)
return __GCONV_ILLEGAL_DESCRIPTOR;
assert (irreversible != NULL);
*irreversible = 0;
--- 31,43 ----
const unsigned char *inbufend, unsigned char **outbuf,
unsigned char *outbufend, size_t *irreversible)
{
! size_t last_step;
int result;
if (cd == (__gconv_t) -1L)
return __GCONV_ILLEGAL_DESCRIPTOR;
+
+ last_step = cd->__nsteps - 1;
assert (irreversible != NULL);
*irreversible = 0;
brgds, H-P
More information about the Libc-alpha
mailing list