Skip to content

Commit 3c78618

Browse files
committed
runtime: check that /proc/self/exe target was not truncated
1 parent afe16a7 commit 3c78618

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/runtime.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ bool build_mount_point(char* mount_dir, const char* const argv0, char const* con
517517
}
518518

519519
int main(int argc, char *argv[]) {
520-
char appimage_path[PATH_MAX];
520+
char appimage_path[PATH_MAX + 1];
521521
char argv0_path[PATH_MAX];
522522
char * arg;
523523

@@ -536,6 +536,10 @@ int main(int argc, char *argv[]) {
536536
perror("Failed to obtain AppImage path");
537537
exit(EXIT_EXECERROR);
538538
}
539+
if (len == sizeof(appimage_path)) {
540+
fprintf(stderr, "AppImage path is too long (%d bytes, and PATH_MAX is %d bytes)", len, sizeof(appimage_path));
541+
exit(EXIT_EXECERROR);
542+
}
539543
appimage_path[len] = '\0';
540544
strcpy(argv0_path, argv[0]);
541545
} else {

0 commit comments

Comments
 (0)