aboutsummaryrefslogtreecommitdiffstats
path: root/shared.c
diff options
context:
space:
mode:
Diffstat (limited to 'shared.c')
-rw-r--r--shared.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/shared.c b/shared.c
index f7b64cf..609bd2a 100644
--- a/shared.c
+++ b/shared.c
@@ -476,15 +476,16 @@ static int is_token_char(char c)
476static char *expand_macro(char *name, int maxlength) 476static 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}