diff options
| author | Daniel Golle | 2024-07-07 16:54:49 +0000 |
|---|---|---|
| committer | Daniel Golle | 2024-07-07 17:00:35 +0000 |
| commit | f230c11771875adc1f74bef013e8cea1fa1867bc (patch) | |
| tree | ef23609cdb6d0450316e77441f0d70fe99943eff | |
| parent | a8cf5480268f90da1ef0f0ea13ffbee10a78dd27 (diff) | |
| download | procd-f230c11771875adc1f74bef013e8cea1fa1867bc.tar.gz | |
utils: use strlcpy when appropriate
For util functions called with a buffer and length parameter we should
use strlcpy() instead of strncpy(), as those functions are called with
sizeof(buffer) as parameter.
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
| -rw-r--r-- | utils/utils.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/utils/utils.c b/utils/utils.c index aa37c86..1939dbd 100644 --- a/utils/utils.c +++ b/utils/utils.c @@ -156,7 +156,7 @@ char *get_active_console(char *out, int len) char *newline = strtok(line, "\n"); if (newline != NULL) { - strncpy(out, newline, len); + strlcpy(out, newline, len); return out; } @@ -192,8 +192,7 @@ char *get_cmdline_val_offset(const char *name, char *out, int len, int offset) if (i++ < offset) continue; - strncpy(out, &sep[1], len); - out[len-1] = 0; + strlcpy(out, &sep[1], len); return out; } |