Skip to content

Commit 5941718

Browse files
committed
- fix some cmd paths problem (cmd_ls, cmd_cd...)
1 parent 32fcfb4 commit 5941718

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

psp2shell_cli/source/main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,8 @@ void *msg_thread(void *unused) {
229229
}
230230

231231
fflush(stdout);
232-
if (msg.buffer[strlen(msg.buffer) - 1] == '\n') { // allow printing to the shell without new line
232+
ssize_t len = strlen(msg.buffer);
233+
if (msg.buffer[len - 1] == '\n') { // allow printing to the shell without new line
233234
rl_refresh_line(0, 0);
234235
}
235236

psp2shell_m/source/cmd.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ static void toAbsolutePath(s_FileList *fileList, char *path) {
3737

3838
char *p = strrchr(path, ':');
3939
if (!p) { // relative path
40-
snprintf(path, MAX_PATH_LENGTH, "%s/%s", fileList->path, path);
40+
char np[MAX_PATH_LENGTH];
41+
strncpy(np, path, MAX_PATH_LENGTH);
42+
snprintf(path, MAX_PATH_LENGTH, "%s/%s", fileList->path, np);
4143
}
4244
}
4345

0 commit comments

Comments
 (0)