diff options
Diffstat (limited to 'shared.c')
-rw-r--r-- | shared.c | 7 |
1 files changed, 4 insertions, 3 deletions
@@ -476,15 +476,16 @@ static int is_token_char(char c) | |||
476 | static char *expand_macro(char *name, int maxlength) | 476 | static char *expand_macro(char *name, int maxlength) |
477 | { | 477 | { |
478 | char *value; | 478 | char *value; |
479 | int len; | 479 | size_t len; |
480 | 480 | ||
481 | len = 0; | 481 | len = 0; |
482 | value = getenv(name); | 482 | value = getenv(name); |
483 | if (value) { | 483 | if (value) { |
484 | len = strlen(value); | 484 | len = strlen(value) + 1; |
485 | if (len > maxlength) | 485 | if (len > maxlength) |
486 | len = maxlength; | 486 | len = maxlength; |
487 | strncpy(name, value, len); | 487 | strlcpy(name, value, len); |
488 | --len; | ||
488 | } | 489 | } |
489 | return name + len; | 490 | return name + len; |
490 | } | 491 | } |