summaryrefslogtreecommitdiffstats
path: root/tools/afcclient.c
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2026-06-10 09:43:52 +0200
committerGravatar Nikias Bassen2026-06-10 09:43:52 +0200
commit38a80d7ec157cdf1afb047b6ff99bbfcc166473f (patch)
treed7ab699650483da92955ba985b7fbf8cd2fdce97 /tools/afcclient.c
parent5ca453f9e3950b1f24b51e4cdf255236e34254c4 (diff)
downloadlibimobiledevice-38a80d7ec157cdf1afb047b6ff99bbfcc166473f.tar.gz
libimobiledevice-38a80d7ec157cdf1afb047b6ff99bbfcc166473f.tar.bz2
tools/afcclient: Fix `cd` handling code
Not all path would update curdir_len, which resulted in copying too many or not enough bytes when changing the directory.
Diffstat (limited to 'tools/afcclient.c')
-rw-r--r--tools/afcclient.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/tools/afcclient.c b/tools/afcclient.c
index 2667e52..e71aea4 100644
--- a/tools/afcclient.c
+++ b/tools/afcclient.c
@@ -332,7 +332,9 @@ static char* get_realpath(const char* path)
for (int i = 0; i < c_count; i++) {
if (!strcmp(comps[i].str, "..")) {
- o--;
+ if (o > 1) {
+ o--;
+ }
continue;
} else if (!strcmp(comps[i].str, ".")) {
continue;
@@ -1202,8 +1204,10 @@ static void handle_cd(afc_client_t afc, int argc, char** argv)
}
if (p == curdir) {
*(p+1) = '\0';
+ curdir_len = 1;
} else {
*p = '\0';
+ curdir_len = strlen(curdir);
}
return;
}
@@ -1227,7 +1231,6 @@ static void handle_cd(afc_client_t afc, int argc, char** argv)
free(path);
return;
}
-
free(curdir);
curdir = path;
curdir_len = strlen(curdir);