blob: 3752728c8e5aa104b43520d520dc4d18fc5c88cd (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
Taken from Fedora
--- portable.c
+++ portable.c
@@ -364,6 +364,31 @@
show_dir(direntry);
}
#endif
+ char *p;
+ /* take off '../' */
+ while ((p = strstr( direntry->dirname, "../" )) != NULL) {
+ while (*(p+3) != '\0') {
+ *p = *(p + 3);
+ p++;
+ }
+ *p = *(p+3); /* move last null */
+ //printf("zoo: skipped \"../\" path component in '%s'\n", direntry->dirname);
+ }
+ /* take off '/' */
+ if ( direntry->dirname[0] == '/' ) {
+ p = direntry->dirname;
+ while (*p != '\0') {
+ *p = *(p + 1);
+ p++;
+ }
+ *p = *(p+1); /* move last null */
+ //printf("zoo: skipped \"/\" path component in '%s'\n", direntry->dirname);
+ }
+ /* take off '..' */
+ if(!strcmp(direntry->dirname, ".."))
+ direntry->dirname[0] = '\0';
+ /* direntry->dirlen = strlen(direntry->dirname); */
+
return (0);
}
|