commit 1064e36

Devine Lu Linvega  ·  2024-11-14 19:19:58 +0000 UTC
parent 53c1974
Removed sandbox escape
1 files changed,  +4, -9
+4, -9
 1@@ -318,12 +318,8 @@ file_read_dir(UxnFile *c, char *dest, Uint16 len)
 2 		if(c->de->d_name[0] == '.' && c->de->d_name[1] == '\0')
 3 			continue;
 4 		if(strcmp(c->de->d_name, "..") == 0) {
 5-			/* hide "sandbox/.." */
 6 			char cwd[PATH_MAX] = {'\0'}, *t;
 7-			/* Note there's [currently] no way of chdir()ing from uxn, so $PWD
 8-			* is always the sandbox top level. */
 9 			getcwd(cwd, sizeof(cwd));
10-			/* We already checked that c->current_filename exists so don't need a wrapper. */
11 			t = realpath(c->current_filename, NULL);
12 			if(strcmp(cwd, t) == 0) {
13 				free(t);
14@@ -390,7 +386,7 @@ file_check_sandbox(UxnFile *c)
15 }
16 
17 static Uint16
18-file_init(UxnFile *c, char *filename, size_t max_len, int override_sandbox)
19+file_init(UxnFile *c, char *filename, size_t max_len)
20 {
21 	char *p = c->current_filename;
22 	size_t len = sizeof(c->current_filename);
23@@ -398,8 +394,7 @@ file_init(UxnFile *c, char *filename, size_t max_len, int override_sandbox)
24 	if(len > max_len) len = max_len;
25 	while(len) {
26 		if((*p++ = *filename++) == '\0') {
27-			if(!override_sandbox) /* override sandbox for loading roms */
28-				file_check_sandbox(c);
29+			file_check_sandbox(c);
30 			return 0;
31 		}
32 		len--;
33@@ -540,7 +535,7 @@ file_deo(Uint8 port)
34 		break;
35 	case 0xa9:
36 		addr = PEEK2(&uxn.dev[0xa8]);
37-		res = file_init(&uxn_file[0], (char *)&uxn.ram[addr], 0x10000 - addr, 0);
38+		res = file_init(&uxn_file[0], (char *)&uxn.ram[addr], 0x10000 - addr);
39 		POKE2(&uxn.dev[0xa2], res);
40 		break;
41 	case 0xad:
42@@ -574,7 +569,7 @@ file_deo(Uint8 port)
43 		break;
44 	case 0xb9:
45 		addr = PEEK2(&uxn.dev[0xb8]);
46-		res = file_init(&uxn_file[1], (char *)&uxn.ram[addr], 0x10000 - addr, 0);
47+		res = file_init(&uxn_file[1], (char *)&uxn.ram[addr], 0x10000 - addr);
48 		POKE2(&uxn.dev[0xb2], res);
49 		break;
50 	case 0xbd: