this repo has no description
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix .. in vchroot

+33 -5
+33 -5
src/kernel/emulation/linux/vchroot_userspace.c
··· 49 49 #define LINUX_S_IFMT 00170000 50 50 #define LINUX_S_IFLNK 0120000 51 51 52 - #define __simple_printf(...) 53 - // #define __simple_printf __simple_kprintf // For bug hunting 52 + // #define __simple_printf(...) 53 + #define __simple_printf __simple_kprintf // For bug hunting 54 54 55 55 #endif 56 56 ··· 190 190 return rv; 191 191 } 192 192 193 - ctxt.current_path_len = rv; 194 - ctxt.current_path[rv] = '\0'; 193 + // If we got "/", then turn it into "", because our algorithm will add a trailing slash later 194 + if (rv == 1 && ctxt.current_path[0] == '/') 195 + { 196 + ctxt.current_path[0] = '\0'; 197 + ctxt.current_path_len = 0; 198 + } 199 + else 200 + { 201 + ctxt.current_path_len = rv; 202 + ctxt.current_path[rv] = '\0'; 203 + } 204 + 205 + // Are we outside the vchrooted area already? 206 + if (ctxt.current_path_len < ctxt.current_root_len || strncmp(ctxt.current_path, ctxt.current_root, ctxt.current_root_len) != 0) 207 + { 208 + ctxt.current_root = ""; 209 + ctxt.current_root_len = 0; 210 + } 195 211 } 196 212 197 213 int rv = vchroot_run(input_path, &ctxt); ··· 236 252 237 253 if (len == 2 && input_path[0] == '.' && input_path[1] == '.') // .. 238 254 { 255 + // Returning back into the vchrooted area 239 256 if (ctxt->current_path_len <= 1) 240 - return -LINUX_ENOENT; 257 + { 258 + strcpy(ctxt->current_path, prefix_path); 259 + strcat(ctxt->current_path, EXIT_PATH); 260 + ctxt->current_path_len = prefix_path_len + sizeof(EXIT_PATH); 261 + 262 + ctxt->current_path[ctxt->current_path_len-1] = '/'; 263 + ctxt->current_path[ctxt->current_path_len] = '\0'; 264 + 265 + ctxt->current_root = prefix_path; 266 + ctxt->current_root_len = prefix_path_len; 267 + } 241 268 242 269 // current_path always ends with a slash 243 270 // p points before the last / ··· 448 475 icase_enabled = true; 449 476 450 477 struct vchroot_expand_args args; 478 + args.dfd = -100; 451 479 strcpy(args.path, argv[2]); 452 480 453 481 int rv = vchroot_expand(&args);