mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Don't walk off front of string when stripping newline
If the string was zero-length to begin with, or consists of only newline characters, nothing stopped us from incrementing right off the front of the string. Ensure len stays above zero the whole time. Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
a42e52a09f
commit
96c4b1c303
@ -219,7 +219,7 @@ size_t _alpm_strip_newline(char *str)
|
||||
return 0;
|
||||
}
|
||||
len = strlen(str);
|
||||
while(str[len - 1] == '\n') {
|
||||
while(len > 0 && str[len - 1] == '\n') {
|
||||
len--;
|
||||
}
|
||||
str[len] = '\0';
|
||||
|
Loading…
Reference in New Issue
Block a user