diff options
Diffstat (limited to 'src/firejail/appimage.c')
-rw-r--r-- | src/firejail/appimage.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/firejail/appimage.c b/src/firejail/appimage.c index 6a9ca1679..0d1f8cb4d 100644 --- a/src/firejail/appimage.c +++ b/src/firejail/appimage.c | |||
@@ -51,6 +51,7 @@ void appimage_set(const char *appimage) { | |||
51 | printf("AppImage ELF size %lu\n", size); | 51 | printf("AppImage ELF size %lu\n", size); |
52 | 52 | ||
53 | // open appimage file | 53 | // open appimage file |
54 | /* coverity[toctou] */ | ||
54 | int ffd = open(appimage, O_RDONLY|O_CLOEXEC); | 55 | int ffd = open(appimage, O_RDONLY|O_CLOEXEC); |
55 | if (ffd == -1) { | 56 | if (ffd == -1) { |
56 | fprintf(stderr, "Error: cannot open AppImage file\n"); | 57 | fprintf(stderr, "Error: cannot open AppImage file\n"); |
@@ -74,6 +75,10 @@ void appimage_set(const char *appimage) { | |||
74 | errExit("asprintf"); | 75 | errExit("asprintf"); |
75 | 76 | ||
76 | int lfd = open(devloop, O_RDONLY); | 77 | int lfd = open(devloop, O_RDONLY); |
78 | if (lfd == -1) { | ||
79 | fprintf(stderr, "Error: cannot open %s\n", devloop); | ||
80 | exit(1); | ||
81 | } | ||
77 | if (ioctl(lfd, LOOP_SET_FD, ffd) == -1) { | 82 | if (ioctl(lfd, LOOP_SET_FD, ffd) == -1) { |
78 | fprintf(stderr, "Error: cannot configure the loopback device\n"); | 83 | fprintf(stderr, "Error: cannot configure the loopback device\n"); |
79 | exit(1); | 84 | exit(1); |
@@ -118,7 +123,7 @@ void appimage_set(const char *appimage) { | |||
118 | EUID_USER(); | 123 | EUID_USER(); |
119 | 124 | ||
120 | // set environment | 125 | // set environment |
121 | if (appimage && setenv("APPIMAGE", appimage, 1) < 0) | 126 | if (setenv("APPIMAGE", appimage, 1) < 0) |
122 | errExit("setenv"); | 127 | errExit("setenv"); |
123 | if (mntdir && setenv("APPDIR", mntdir, 1) < 0) | 128 | if (mntdir && setenv("APPDIR", mntdir, 1) < 0) |
124 | errExit("setenv"); | 129 | errExit("setenv"); |
@@ -170,8 +175,10 @@ void appimage_clear(void) { | |||
170 | 175 | ||
171 | if (devloop) { | 176 | if (devloop) { |
172 | int lfd = open(devloop, O_RDONLY); | 177 | int lfd = open(devloop, O_RDONLY); |
173 | rv = ioctl(lfd, LOOP_CLR_FD, 0); | 178 | if (lfd != -1) { |
174 | (void) rv; | 179 | rv = ioctl(lfd, LOOP_CLR_FD, 0); |
175 | close(lfd); | 180 | (void) rv; |
181 | close(lfd); | ||
182 | } | ||
176 | } | 183 | } |
177 | } | 184 | } |