mirror of
https://github.com/systemd/systemd.git
synced 2024-12-23 21:35:11 +03:00
*_id: fix zero length in set_str()
Thanks to Olaf Hering <olh@suse.de> Signed-off-by: Kay Sievers <kay.sievers@suse.de>
This commit is contained in:
parent
8c11a2f0ff
commit
c907c823c3
@ -68,7 +68,7 @@ static void set_str(char *to, const char *from, size_t count)
|
||||
|
||||
/* strip trailing whitespace */
|
||||
len = strnlen(from, count);
|
||||
while (isspace(from[len-1]))
|
||||
while (len && isspace(from[len-1]))
|
||||
len--;
|
||||
|
||||
/* strip leading whitespace */
|
||||
|
@ -107,7 +107,7 @@ static void set_str(char *to, const char *from, size_t count)
|
||||
|
||||
/* strip trailing whitespace */
|
||||
len = strnlen(from, count);
|
||||
while (isspace(from[len-1]))
|
||||
while (len && isspace(from[len-1]))
|
||||
len--;
|
||||
|
||||
/* strip leading whitespace */
|
||||
|
@ -82,7 +82,7 @@ static void set_str(char *to, const char *from, size_t count)
|
||||
|
||||
/* strip trailing whitespace */
|
||||
len = strnlen(from, count);
|
||||
while (isspace(from[len-1]))
|
||||
while (len && isspace(from[len-1]))
|
||||
len--;
|
||||
|
||||
/* strip leading whitespace */
|
||||
|
@ -66,7 +66,7 @@ static void set_str(char *to, const char *from, size_t count)
|
||||
|
||||
/* strip trailing whitespace */
|
||||
len = strnlen(from, count);
|
||||
while (isspace(from[len-1]))
|
||||
while (len && isspace(from[len-1]))
|
||||
len--;
|
||||
|
||||
/* strip leading whitespace */
|
||||
|
Loading…
Reference in New Issue
Block a user