os2: fix the last character of a response file is splitted

For example, if a response file has the following:

    0123456789

Then, it is splitted into two arguments, 012345678 and 9.

    modified:   os2.c
This commit is contained in:
KO Myung-Hun 2016-03-20 11:25:31 +09:00
parent 8178a963f4
commit 52c47ec69e
1 changed files with 2 additions and 2 deletions

4
os2.c
View File

@ -86,13 +86,13 @@ response(int *argcp, const char ***argvp)
filesize = ftell(f);
fseek(f, 0, SEEK_SET);
line = malloc(filesize + 1);
line = malloc(filesize + 1 + 1); /* 1 for type, 1 for NUL */
if (!line)
goto exit_out_of_memory;
line[0] = __KLIBC_ARG_NONZERO | __KLIBC_ARG_RESPONSE;
l = line + 1;
while (fgets(l, filesize - (l - line - 1), f)) {
while (fgets(l, (filesize + 1) - (l - (line + 1)), f)) {
p = strchr(l, '\n');
if (p) {
/* if a line ends with '\',