mirror of
https://github.com/Stichting-MINIX-Research-Foundation/pkgsrc-ng.git
synced 2025-09-10 21:09:31 -04:00
78 lines
1.7 KiB
Plaintext
78 lines
1.7 KiB
Plaintext
$NetBSD: patch-ad,v 1.4 2010/01/09 19:10:46 dholland Exp $
|
|
|
|
1. security fix
|
|
2. utimes() fixes for netbsd-6 time_t
|
|
|
|
upstream: (1) unknown (2) not reported, docs in .jp only, wakarimasen :(
|
|
|
|
--- src/lhext.c.orig 2000-10-04 10:57:38.000000000 -0400
|
|
+++ src/lhext.c 2009-02-13 18:42:35.000000000 -0500
|
|
@@ -143,13 +143,15 @@ adjust_info(name, hdr)
|
|
char *name;
|
|
LzHeader *hdr;
|
|
{
|
|
- time_t utimebuf[2];
|
|
+ struct timeval utimebuf[2];
|
|
|
|
/* adjust file stamp */
|
|
- utimebuf[0] = utimebuf[1] = hdr->unix_last_modified_stamp;
|
|
+ utimebuf[0].tv_sec = hdr->unix_last_modified_stamp;
|
|
+ utimebuf[0].tv_usec = 0;
|
|
+ utimebuf[1] = utimebuf[0];
|
|
|
|
if ((hdr->unix_mode & UNIX_FILE_TYPEMASK) != UNIX_FILE_SYMLINK)
|
|
- utime(name, utimebuf);
|
|
+ utimes(name, utimebuf);
|
|
|
|
if (hdr->extend_type == EXTEND_UNIX
|
|
|| hdr->extend_type == EXTEND_OS68K
|
|
@@ -190,8 +192,13 @@ extract_one(afp, hdr)
|
|
q = (char *) rindex(hdr->name, '/') + 1;
|
|
}
|
|
else {
|
|
+ if (is_directory_traversal(q)) {
|
|
+ fprintf(stderr, "Possible directory traversal hack attempt in %s\n", q);
|
|
+ exit(111);
|
|
+ }
|
|
+
|
|
if (*q == '/') {
|
|
- q++;
|
|
+ while (*q == '/') { q++; }
|
|
/*
|
|
* if OSK then strip device name
|
|
*/
|
|
@@ -419,6 +426,33 @@ cmd_extract()
|
|
return;
|
|
}
|
|
|
|
+int
|
|
+is_directory_traversal(char *string)
|
|
+{
|
|
+ unsigned int type = 0; /* 0 = new, 1 = only dots, 2 = other chars than dots */
|
|
+ char *temp;
|
|
+
|
|
+ temp = string;
|
|
+
|
|
+ while (*temp != 0) {
|
|
+ if (temp[0] == '/') {
|
|
+ if (type == 1) { return 1; }
|
|
+ type = 0;
|
|
+ temp++;
|
|
+ continue;
|
|
+ }
|
|
+
|
|
+ if ((temp[0] == '.') && (type < 2))
|
|
+ type = 1;
|
|
+ if (temp[0] != '.')
|
|
+ type = 2;
|
|
+
|
|
+ temp++;
|
|
+ } /* while */
|
|
+
|
|
+ return (type == 1);
|
|
+}
|
|
+
|
|
/* Local Variables: */
|
|
/* mode:c */
|
|
/* tab-width:4 */
|