[uClibc-cvs] uClibc/libc/termios ttyname.c,1.10,1.11
Erik Andersen
andersen at uclibc.org
Mon Sep 1 14:56:36 UTC 2003
Update of /var/cvs/uClibc/libc/termios
In directory winder:/tmp/cvs-serv9579/libc/termios
Modified Files:
ttyname.c
Log Message:
Greg Nutt writes:
Attached is a patch for a bug I found in libc/termios/ttyname.c.
Essentially the length of the buffer is calculated incorrectly in a
strncpy call and then the null terminator is placed on the byte after
the buffer.
This probably cause some very strange behavior on my system (it ended up
setting malloc's heapsize to zero) but may be innocuous on other systems.
Index: ttyname.c
===================================================================
RCS file: /var/cvs/uClibc/libc/termios/ttyname.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ttyname.c 5 Nov 2002 16:28:56 -0000 1.10
+++ ttyname.c 1 Sep 2003 14:56:33 -0000 1.11
@@ -19,8 +19,8 @@
len = strlen(dirname) + 1;
while ((d = readdir(fp)) != 0) {
- strncpy(buf+len, d->d_name, buflen);
- buf[buflen]='\0';
+ strncpy(buf+len, d->d_name, buflen-len);
+ buf[buflen-1]='\0';
#if 0
/* Stupid filesystems like cramfs fail to guarantee that
* st_ino and st_dev uniquely identify a file, contrary to
More information about the uClibc-cvs
mailing list