diff options
Diffstat (limited to 'usr/gen_init_cpio.c')
-rw-r--r-- | usr/gen_init_cpio.c | 43 |
1 files changed, 23 insertions, 20 deletions
diff --git a/usr/gen_init_cpio.c b/usr/gen_init_cpio.c index af0f22fb1ef7..aca6edcbbc6f 100644 --- a/usr/gen_init_cpio.c +++ b/usr/gen_init_cpio.c | |||
@@ -303,7 +303,7 @@ static int cpio_mkfile(const char *name, const char *location, | |||
303 | int retval; | 303 | int retval; |
304 | int rc = -1; | 304 | int rc = -1; |
305 | int namesize; | 305 | int namesize; |
306 | int i; | 306 | unsigned int i; |
307 | 307 | ||
308 | mode |= S_IFREG; | 308 | mode |= S_IFREG; |
309 | 309 | ||
@@ -381,25 +381,28 @@ error: | |||
381 | 381 | ||
382 | static char *cpio_replace_env(char *new_location) | 382 | static char *cpio_replace_env(char *new_location) |
383 | { | 383 | { |
384 | char expanded[PATH_MAX + 1]; | 384 | char expanded[PATH_MAX + 1]; |
385 | char env_var[PATH_MAX + 1]; | 385 | char env_var[PATH_MAX + 1]; |
386 | char *start; | 386 | char *start; |
387 | char *end; | 387 | char *end; |
388 | 388 | ||
389 | for (start = NULL; (start = strstr(new_location, "${")); ) { | 389 | for (start = NULL; (start = strstr(new_location, "${")); ) { |
390 | end = strchr(start, '}'); | 390 | end = strchr(start, '}'); |
391 | if (start < end) { | 391 | if (start < end) { |
392 | *env_var = *expanded = '\0'; | 392 | *env_var = *expanded = '\0'; |
393 | strncat(env_var, start + 2, end - start - 2); | 393 | strncat(env_var, start + 2, end - start - 2); |
394 | strncat(expanded, new_location, start - new_location); | 394 | strncat(expanded, new_location, start - new_location); |
395 | strncat(expanded, getenv(env_var), PATH_MAX); | 395 | strncat(expanded, getenv(env_var), |
396 | strncat(expanded, end + 1, PATH_MAX); | 396 | PATH_MAX - strlen(expanded)); |
397 | strncpy(new_location, expanded, PATH_MAX); | 397 | strncat(expanded, end + 1, |
398 | } else | 398 | PATH_MAX - strlen(expanded)); |
399 | break; | 399 | strncpy(new_location, expanded, PATH_MAX); |
400 | } | 400 | new_location[PATH_MAX] = 0; |
401 | 401 | } else | |
402 | return new_location; | 402 | break; |
403 | } | ||
404 | |||
405 | return new_location; | ||
403 | } | 406 | } |
404 | 407 | ||
405 | 408 | ||