diff options
Diffstat (limited to 'arch/um/os-Linux/mem.c')
-rw-r--r-- | arch/um/os-Linux/mem.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/arch/um/os-Linux/mem.c b/arch/um/os-Linux/mem.c index 436f8d20b20f..eedc2d88ef8a 100644 --- a/arch/um/os-Linux/mem.c +++ b/arch/um/os-Linux/mem.c | |||
@@ -9,7 +9,6 @@ | |||
9 | #include <sys/types.h> | 9 | #include <sys/types.h> |
10 | #include <sys/mman.h> | 10 | #include <sys/mman.h> |
11 | #include <sys/statfs.h> | 11 | #include <sys/statfs.h> |
12 | #include "kern_util.h" | ||
13 | #include "user.h" | 12 | #include "user.h" |
14 | #include "mem_user.h" | 13 | #include "mem_user.h" |
15 | #include "init.h" | 14 | #include "init.h" |
@@ -30,7 +29,7 @@ static char *tempdir = NULL; | |||
30 | 29 | ||
31 | static void __init find_tempdir(void) | 30 | static void __init find_tempdir(void) |
32 | { | 31 | { |
33 | char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; | 32 | const char *dirs[] = { "TMP", "TEMP", "TMPDIR", NULL }; |
34 | int i; | 33 | int i; |
35 | char *dir = NULL; | 34 | char *dir = NULL; |
36 | 35 | ||
@@ -59,9 +58,10 @@ static void __init find_tempdir(void) | |||
59 | * read the file as needed. If there's an error, -errno is returned; | 58 | * read the file as needed. If there's an error, -errno is returned; |
60 | * if the end of the file is reached, 0 is returned. | 59 | * if the end of the file is reached, 0 is returned. |
61 | */ | 60 | */ |
62 | static int next(int fd, char *buf, int size, char c) | 61 | static int next(int fd, char *buf, size_t size, char c) |
63 | { | 62 | { |
64 | int n, len; | 63 | ssize_t n; |
64 | size_t len; | ||
65 | char *ptr; | 65 | char *ptr; |
66 | 66 | ||
67 | while((ptr = strchr(buf, c)) == NULL){ | 67 | while((ptr = strchr(buf, c)) == NULL){ |
@@ -172,13 +172,15 @@ int __init make_tempfile(const char *template, char **out_tempname, | |||
172 | 172 | ||
173 | which_tmpdir(); | 173 | which_tmpdir(); |
174 | tempname = malloc(MAXPATHLEN); | 174 | tempname = malloc(MAXPATHLEN); |
175 | if (!tempname) | ||
176 | goto out; | ||
175 | 177 | ||
176 | find_tempdir(); | 178 | find_tempdir(); |
177 | if (template[0] != '/') | 179 | if (template[0] != '/') |
178 | strcpy(tempname, tempdir); | 180 | strcpy(tempname, tempdir); |
179 | else | 181 | else |
180 | tempname[0] = '\0'; | 182 | tempname[0] = '\0'; |
181 | strcat(tempname, template); | 183 | strncat(tempname, template, MAXPATHLEN-1-strlen(tempname)); |
182 | fd = mkstemp(tempname); | 184 | fd = mkstemp(tempname); |
183 | if(fd < 0){ | 185 | if(fd < 0){ |
184 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, | 186 | fprintf(stderr, "open - cannot create %s: %s\n", tempname, |
@@ -268,6 +270,7 @@ void __init check_tmpexec(void) | |||
268 | if(addr == MAP_FAILED){ | 270 | if(addr == MAP_FAILED){ |
269 | err = errno; | 271 | err = errno; |
270 | perror("failed"); | 272 | perror("failed"); |
273 | close(fd); | ||
271 | if(err == EPERM) | 274 | if(err == EPERM) |
272 | printf("%s must be not mounted noexec\n",tempdir); | 275 | printf("%s must be not mounted noexec\n",tempdir); |
273 | exit(1); | 276 | exit(1); |