1 --- Makefile.orig 2006-08-26 13:32:42.000000000 +0200
2 +++ Makefile 2006-08-26 13:34:10.000000000 +0200
5 decode.o: decode.c unarj.h
7 -OBJS = unarj.o decode.o environ.o
8 +sanitize.o: sanitize.c unarj.h
10 +OBJS = unarj.o decode.o environ.o sanitize.o
13 $(CC) $(LDFLAGS) $(OBJS) -o unarj
18 + * Path sanitation code by Ludwig Nussel <ludwig.nussel@suse.de>. Public Domain.
28 +#define PATH_CHAR '/'
31 +#define MIN(x,y) ((x)<(y)?(x):(y))
34 +/* copy src into dest converting the path to a relative one inside the current
35 + * directory. dest must hold at least len bytes */
36 +void copy_path_relative(char *dest, char *src, size_t len)
43 + while(*p && *p == PATH_CHAR) ++p;
47 + p = strchr(src, PATH_CHAR);
48 + if(!p) p = src+strlen(src);
51 + if(p-src == 1 && *src == '.' )
56 + else if(p-src == 2 && *src == '.' && src[1] == '.')
62 + tmp = strrchr(dest, PATH_CHAR);
76 + else /* nothing to pop */
87 + copy = MIN(p-src,len);
88 + memcpy(o, src, copy);
94 + while(*p && *p == PATH_CHAR) ++p;
98 --- unarj.c.orig 2006-08-26 13:41:54.000000000 +0200
99 +++ unarj.c 2006-08-26 13:42:14.000000000 +0200
104 +void copy_path_relative(char *dest, char *src, size_t len);
109 @@ -732,11 +734,11 @@
113 - strncopy(name, &filename[entry_pos], sizeof(name));
114 + copy_path_relative(name, &filename[entry_pos], sizeof(name));
117 strcpy(name, DEFAULT_DIR);
118 - strncopy(name+strlen(name), filename, sizeof(name)-strlen(name));
119 + copy_path_relative(name+strlen(name), filename, sizeof(name)-strlen(name));