Fix change_field() buffer underrun
* lib/fields.c (change_field): Don't point before array start; that has undefined behavior. Signed-off-by: Paul Eggert <eggert@cs.ucla.edu> Signed-off-by: Alejandro Colomar <alx@kernel.org> Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com>
This commit is contained in:
parent
690ca8c238
commit
a926a26f0c
@ -91,8 +91,9 @@ void change_field (char *buf, size_t maxsize, const char *prompt)
|
|||||||
* entering a space. --marekm
|
* entering a space. --marekm
|
||||||
*/
|
*/
|
||||||
|
|
||||||
while (--cp >= newf && isspace (*cp));
|
while (newf < cp && isspace (cp[-1])) {
|
||||||
cp++;
|
cp--;
|
||||||
|
}
|
||||||
*cp = '\0';
|
*cp = '\0';
|
||||||
|
|
||||||
cp = newf;
|
cp = newf;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user