mirror of
https://github.com/opnsense/src.git
synced 2026-06-11 01:30:30 -04:00
Fix trimming spaces writing at index -1 if an empty string is passed
Submitted by: Gennady Proskurin <gprspb@mail.ru>
This commit is contained in:
parent
615b6ea2c8
commit
cbc9c8d8d3
1 changed files with 7 additions and 2 deletions
|
|
@ -87,11 +87,16 @@ static void
|
|||
trimlr(char **buf)
|
||||
{
|
||||
char *walk = *buf;
|
||||
char *last;
|
||||
|
||||
while (isspace(*walk))
|
||||
walk++;
|
||||
while (isspace(walk[strlen(walk) -1]))
|
||||
walk[strlen(walk) -1] = '\0';
|
||||
if (*walk != '\0') {
|
||||
last = walk + strlen(walk) - 1;
|
||||
while (last > walk && isspace(*last))
|
||||
last--;
|
||||
*(last+1) = 0;
|
||||
}
|
||||
|
||||
*buf = walk;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue