This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
EOVERFLOW in fseek()
- From: Sebastian Huber <sebastian dot huber at embedded-brains dot de>
- To: newlib at sourceware dot org
- Date: Wed, 20 Jun 2012 10:28:49 +0200
- Subject: EOVERFLOW in fseek()
Hi,
in "newlib/libc/stdio/fseek.c" we have:
[...]
/*
* We are reading; we can try to optimise.
* Figure out where we are going and where we are now.
*/
if (whence == SEEK_SET)
target = offset;
else
{
#ifdef __USE_INTERNAL_STAT64
if (_fstat64_r (ptr, fp->_file, &st))
#else
if (_fstat_r (ptr, fp->_file, &st))
#endif
goto dumb;
target = st.st_size + offset;
}
if ((long)target != target)
{
ptr->_errno = EOVERFLOW;
_newlib_flockfile_exit (fp);
return EOF;
}
[...]
In "target = st.st_size + offset" we may have a signed integer overflow.
Shouldn't this lead to an EOVERFLOW error?
--
Sebastian Huber, embedded brains GmbH
Address : Obere Lagerstr. 30, D-82178 Puchheim, Germany
Phone : +49 89 18 90 80 79-6
Fax : +49 89 18 90 80 79-9
E-Mail : sebastian.huber@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.