diff options
author | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2013-12-13 18:41:03 +0900 |
---|---|---|
committer | Carsten Haitzler (Rasterman) <raster@rasterman.com> | 2013-12-13 21:26:05 +0900 |
commit | 75fbf9e03a4b163091f7cb4e1ddac26bc241f42b (patch) | |
tree | e1e3e4657cdd965f58331719412c7e11a2b0ab77 /src/lib/ethumb/ethumb.c | |
parent | a99bc8933140aa9aec1933ef691fe76f0079066b (diff) |
ethumb - ensure buf is nul terminated
this SHOULD deal with CID 1039577 and CID 1039576
Diffstat (limited to 'src/lib/ethumb/ethumb.c')
-rw-r--r-- | src/lib/ethumb/ethumb.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/ethumb/ethumb.c b/src/lib/ethumb/ethumb.c index 5104b0fae8..f1c5466be8 100644 --- a/src/lib/ethumb/ethumb.c +++ b/src/lib/ethumb/ethumb.c | |||
@@ -698,13 +698,17 @@ _ethumb_build_absolute_path(const char *path, char buf[PATH_MAX]) | |||
698 | p = buf; | 698 | p = buf; |
699 | 699 | ||
700 | if (path[0] == '/') | 700 | if (path[0] == '/') |
701 | strcpy(p, path); | 701 | { |
702 | strncpy(p, path, PATH_MAX - 1); | ||
703 | p[PATH_MAX - 1] = 0; | ||
704 | } | ||
702 | else if (path[0] == '~') | 705 | else if (path[0] == '~') |
703 | { | 706 | { |
704 | const char *home = getenv("HOME"); | 707 | const char *home = getenv("HOME"); |
705 | if (!home) | 708 | if (!home) |
706 | return NULL; | 709 | return NULL; |
707 | strcpy(p, home); | 710 | strncpy(p, home, PATH_MAX - 1); |
711 | p[PATH_MAX - 1] = 0; | ||
708 | len = strlen(p); | 712 | len = strlen(p); |
709 | p += len; | 713 | p += len; |
710 | p[0] = '/'; | 714 | p[0] = '/'; |
@@ -719,7 +723,8 @@ _ethumb_build_absolute_path(const char *path, char buf[PATH_MAX]) | |||
719 | p += len; | 723 | p += len; |
720 | p[0] = '/'; | 724 | p[0] = '/'; |
721 | p++; | 725 | p++; |
722 | strcpy(p, path); | 726 | strncpy(p, path, PATH_MAX - 1 - len - 1); |
727 | p[PATH_MAX - 1 - len - 1] = 0; | ||
723 | } | 728 | } |
724 | 729 | ||
725 | return buf; | 730 | return buf; |