The buffer returned by fgenln is not a "C" string and might not be NUL

terminated. Make sure that it is before using it.

Reviewed by:	marck@
MFC after:	3 days
This commit is contained in:
Stephane E. Potvin 2009-09-16 19:53:29 +00:00
parent d830c305ea
commit 68961d1200
2 changed files with 3 additions and 1 deletions

View File

@ -34,6 +34,7 @@
#define Strcpy (void)strcpy
#define Strcat (void)strcat
#define Strlcpy (void)strlcpy
#define Strncpy (void)strncpy
#define Strlcat (void)strlcat
/* NeXT declares malloc and realloc incompatibly from us in some of

View File

@ -1176,7 +1176,8 @@ pgets(bool do_indent)
indent++;
}
}
Strlcpy(buf, line, len + 1 - skipped);
Strncpy(buf, line, len - skipped);
buf[len - skipped] = '\0';
}
return len;
}