Skip to content

Commit

Permalink
runtime: check that /proc/self/exe target was not truncated
Browse files Browse the repository at this point in the history
  • Loading branch information
s-zeid committed Feb 1, 2022
1 parent afe16a7 commit 3c78618
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/runtime.c
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@ bool build_mount_point(char* mount_dir, const char* const argv0, char const* con
}

int main(int argc, char *argv[]) {
char appimage_path[PATH_MAX];
char appimage_path[PATH_MAX + 1];
char argv0_path[PATH_MAX];
char * arg;

Expand All @@ -536,6 +536,10 @@ int main(int argc, char *argv[]) {
perror("Failed to obtain AppImage path");
exit(EXIT_EXECERROR);
}
if (len == sizeof(appimage_path)) {
fprintf(stderr, "AppImage path is too long (%d bytes, and PATH_MAX is %d bytes)", len, sizeof(appimage_path));
exit(EXIT_EXECERROR);
}
appimage_path[len] = '\0';
strcpy(argv0_path, argv[0]);
} else {
Expand Down

0 comments on commit 3c78618

Please sign in to comment.