Fixed a problem with PlatformGetLine() which was causing a buffer overrun.

With thanks to mark@heilpern.com.
Issue #581.


git-svn-id: http://picoc.googlecode.com/svn/trunk@602 21eae674-98b7-11dd-bd71-f92a316d2d60
This commit is contained in:
zik.saleeba 2013-10-14 23:38:00 +00:00
parent 6e9b4b3c84
commit ed54c51916

View file

@ -46,9 +46,9 @@ char *PlatformGetLine(char *Buf, int MaxLen, const char *Prompt)
if (InLine == NULL) if (InLine == NULL)
return NULL; return NULL;
Buf[MaxLen] = '\0'; Buf[MaxLen-1] = '\0';
strncpy(Buf, InLine, MaxLen-1); strncpy(Buf, InLine, MaxLen-2);
strncat(Buf, "\n", MaxLen-1); strncat(Buf, "\n", MaxLen-2);
if (InLine[0] != '\0') if (InLine[0] != '\0')
add_history(InLine); add_history(InLine);