diff options
| -rw-r--r-- | tools/afcclient.c | 10 | 
1 files changed, 5 insertions, 5 deletions
diff --git a/tools/afcclient.c b/tools/afcclient.c index 1f7df5e..1546a6c 100644 --- a/tools/afcclient.c +++ b/tools/afcclient.c  | |||
| @@ -838,7 +838,7 @@ static uint8_t get_file(afc_client_t afc, const char *srcpath, const char *dstpa | |||
| 838 | p++; | 838 | p++; | 
| 839 | continue; | 839 | continue; | 
| 840 | } | 840 | } | 
| 841 | size_t len = srcpath_is_root ? strlen(*p) + 1 : srcpath_len + 1 + strlen(*p) + 1; | 841 | size_t len = srcpath_is_root ? (strlen(*p) + 2) : (srcpath_len + 1 + strlen(*p) + 1); | 
| 842 | char *testpath = (char *) malloc(len); | 842 | char *testpath = (char *) malloc(len); | 
| 843 | if (srcpath_is_root) { | 843 | if (srcpath_is_root) { | 
| 844 | snprintf(testpath, len, "/%s", *p); | 844 | snprintf(testpath, len, "/%s", *p); | 
| @@ -846,7 +846,7 @@ static uint8_t get_file(afc_client_t afc, const char *srcpath, const char *dstpa | |||
| 846 | snprintf(testpath, len, "%s/%s", srcpath, *p); | 846 | snprintf(testpath, len, "%s/%s", srcpath, *p); | 
| 847 | } | 847 | } | 
| 848 | uint8_t dst_is_root = strcmp(srcpath, "/") == 0; | 848 | uint8_t dst_is_root = strcmp(srcpath, "/") == 0; | 
| 849 | size_t dst_len = dst_is_root ? strlen(*p) + 1 : strlen(dstpath) + 1 + strlen(*p) + 1; | 849 | size_t dst_len = dst_is_root ? (strlen(*p) + 2) : (strlen(dstpath) + 1 + strlen(*p) + 1); | 
| 850 | char *newdst = (char *) malloc(dst_len); | 850 | char *newdst = (char *) malloc(dst_len); | 
| 851 | if (dst_is_root) { | 851 | if (dst_is_root) { | 
| 852 | snprintf(newdst, dst_len, "/%s", *p); | 852 | snprintf(newdst, dst_len, "/%s", *p); | 
| @@ -924,7 +924,7 @@ static void handle_get(afc_client_t afc, int argc, char **argv) | |||
| 924 | if (is_directory(dstpath)) { | 924 | if (is_directory(dstpath)) { | 
| 925 | const char *basen = path_get_basename(argv[0]); | 925 | const char *basen = path_get_basename(argv[0]); | 
| 926 | uint8_t dst_is_root = strcmp(dstpath, "/") == 0; | 926 | uint8_t dst_is_root = strcmp(dstpath, "/") == 0; | 
| 927 | size_t len = dst_is_root ? (strlen(basen) + 1) : (strlen(dstpath) + 1 + strlen(basen) + 1); | 927 | size_t len = dst_is_root ? (strlen(basen) + 2) : (strlen(dstpath) + 1 + strlen(basen) + 1); | 
| 928 | char *newdst = (char *) malloc(len); | 928 | char *newdst = (char *) malloc(len); | 
| 929 | if (dst_is_root) { | 929 | if (dst_is_root) { | 
| 930 | snprintf(newdst, len, "/%s", basen); | 930 | snprintf(newdst, len, "/%s", basen); | 
| @@ -1074,7 +1074,7 @@ static uint8_t put_file(afc_client_t afc, const char *srcpath, const char *dstpa | |||
| 1074 | char *fpath = string_build_path(srcpath, ep->d_name, NULL); | 1074 | char *fpath = string_build_path(srcpath, ep->d_name, NULL); | 
| 1075 | if (fpath) { | 1075 | if (fpath) { | 
| 1076 | uint8_t dst_is_root = strcmp(dstpath, "/") == 0; | 1076 | uint8_t dst_is_root = strcmp(dstpath, "/") == 0; | 
| 1077 | size_t len = dst_is_root ? strlen(ep->d_name) + 1 : strlen(dstpath) + 1 + strlen(ep->d_name) + 1; | 1077 | size_t len = dst_is_root ? (strlen(ep->d_name) + 2) : (strlen(dstpath) + 1 + strlen(ep->d_name) + 1); | 
| 1078 | char *newdst = (char *) malloc(len); | 1078 | char *newdst = (char *) malloc(len); | 
| 1079 | if (dst_is_root) { | 1079 | if (dst_is_root) { | 
| 1080 | snprintf(newdst, len, "/%s", ep->d_name); | 1080 | snprintf(newdst, len, "/%s", ep->d_name); | 
| @@ -1173,7 +1173,7 @@ static void handle_put(afc_client_t afc, int argc, char **argv) | |||
| 1173 | if (is_dir) { | 1173 | if (is_dir) { | 
| 1174 | const char *basen = path_get_basename(srcpath); | 1174 | const char *basen = path_get_basename(srcpath); | 
| 1175 | uint8_t dst_is_root = strcmp(dstpath, "/") == 0; | 1175 | uint8_t dst_is_root = strcmp(dstpath, "/") == 0; | 
| 1176 | size_t len = dst_is_root ? strlen(basen) + 1 : strlen(dstpath) + 1 + strlen(basen) + 1; | 1176 | size_t len = dst_is_root ? (strlen(basen) + 2) : (strlen(dstpath) + 1 + strlen(basen) + 1); | 
| 1177 | char *newdst = (char *) malloc(len); | 1177 | char *newdst = (char *) malloc(len); | 
| 1178 | if (dst_is_root) { | 1178 | if (dst_is_root) { | 
| 1179 | snprintf(newdst, len, "/%s", basen); | 1179 | snprintf(newdst, len, "/%s", basen); | 
