make sure the buffer holding the command line is always NUL terminated

This commit is contained in:
Mike Frysinger 2009-03-06 02:10:10 +00:00
parent ebf4d38912
commit 69a0d44d75
1 changed files with 2 additions and 1 deletions

View File

@ -1408,7 +1408,8 @@ main (argc, argv)
argv[1] = cp; /* head of new arg block */ argv[1] = cp; /* head of new arg block */
fprintf (stderr, "Cmd line: "); fprintf (stderr, "Cmd line: ");
fflush (stderr); /* I dont care if it's unbuffered or not! */ fflush (stderr); /* I dont care if it's unbuffered or not! */
insaved = read (0, cp, BIGSIZ); /* we're gonna fake fgets() here */ insaved = read (0, cp, BIGSIZ-1); /* we're gonna fake fgets() here */
cp[BIGSIZ-1] = '\0';
if (insaved <= 0) if (insaved <= 0)
bail ("wrong"); bail ("wrong");
x = findline (cp, insaved); x = findline (cp, insaved);