1
0
Fork 0

Don't forget to terminate the string

This commit is contained in:
ehofman 2003-08-28 12:03:15 +00:00
parent da7d172d37
commit 0599f873dc

View file

@ -64,7 +64,7 @@ int reads(int fd, char *buf, unsigned int len) {
int res;
unsigned int i;
for (i=0;
(i < len) && ((res = read(fd, &c, 1)) != 0)
(i < (len-1)) && ((res = read(fd, &c, 1)) != 0)
&& ((c != '\n') && (c != '\r'));
i++)
buf[i] = c;
@ -72,6 +72,8 @@ int reads(int fd, char *buf, unsigned int len) {
if (buf[i] == '\r')
buf[i] = '\n';
buf[++i] = '\0';
return res;
}