mem.c (512b6fb1c14d4c34f23a3419b0789ad01914a899) mem.c (c9a3072d13e4b8a6549ecc1db6390a55c7ee2ddf)
1#include <stdio.h>
2#include <stdlib.h>
3#include <stddef.h>
4#include <stdarg.h>
5#include <unistd.h>
6#include <errno.h>
7#include <string.h>
8#include <fcntl.h>

--- 158 unchanged lines hidden (view full) ---

167int __init make_tempfile(const char *template, char **out_tempname,
168 int do_unlink)
169{
170 char *tempname;
171 int fd;
172
173 which_tmpdir();
174 tempname = malloc(MAXPATHLEN);
1#include <stdio.h>
2#include <stdlib.h>
3#include <stddef.h>
4#include <stdarg.h>
5#include <unistd.h>
6#include <errno.h>
7#include <string.h>
8#include <fcntl.h>

--- 158 unchanged lines hidden (view full) ---

167int __init make_tempfile(const char *template, char **out_tempname,
168 int do_unlink)
169{
170 char *tempname;
171 int fd;
172
173 which_tmpdir();
174 tempname = malloc(MAXPATHLEN);
175 if (!tempname)
176 goto out;
175
176 find_tempdir();
177 if (template[0] != '/')
178 strcpy(tempname, tempdir);
179 else
180 tempname[0] = '\0';
177
178 find_tempdir();
179 if (template[0] != '/')
180 strcpy(tempname, tempdir);
181 else
182 tempname[0] = '\0';
181 strcat(tempname, template);
183 strncat(tempname, template, MAXPATHLEN-1-strlen(tempname));
182 fd = mkstemp(tempname);
183 if(fd < 0){
184 fprintf(stderr, "open - cannot create %s: %s\n", tempname,
185 strerror(errno));
186 goto out;
187 }
188 if(do_unlink && (unlink(tempname) < 0)){
189 perror("unlink");

--- 73 unchanged lines hidden (view full) ---

263
264 addr = mmap(NULL, UM_KERN_PAGE_SIZE,
265 PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
266 printf("Checking PROT_EXEC mmap in %s...",tempdir);
267 fflush(stdout);
268 if(addr == MAP_FAILED){
269 err = errno;
270 perror("failed");
184 fd = mkstemp(tempname);
185 if(fd < 0){
186 fprintf(stderr, "open - cannot create %s: %s\n", tempname,
187 strerror(errno));
188 goto out;
189 }
190 if(do_unlink && (unlink(tempname) < 0)){
191 perror("unlink");

--- 73 unchanged lines hidden (view full) ---

265
266 addr = mmap(NULL, UM_KERN_PAGE_SIZE,
267 PROT_READ | PROT_WRITE | PROT_EXEC, MAP_PRIVATE, fd, 0);
268 printf("Checking PROT_EXEC mmap in %s...",tempdir);
269 fflush(stdout);
270 if(addr == MAP_FAILED){
271 err = errno;
272 perror("failed");
273 close(fd);
271 if(err == EPERM)
272 printf("%s must be not mounted noexec\n",tempdir);
273 exit(1);
274 }
275 printf("OK\n");
276 munmap(addr, UM_KERN_PAGE_SIZE);
277
278 close(fd);
279}
274 if(err == EPERM)
275 printf("%s must be not mounted noexec\n",tempdir);
276 exit(1);
277 }
278 printf("OK\n");
279 munmap(addr, UM_KERN_PAGE_SIZE);
280
281 close(fd);
282}