summaryrefslogtreecommitdiffstats
path: root/main/tzdata/0001-posixtz-fix-up-lseek.patch
diff options
context:
space:
mode:
Diffstat (limited to 'main/tzdata/0001-posixtz-fix-up-lseek.patch')
-rw-r--r--main/tzdata/0001-posixtz-fix-up-lseek.patch47
1 files changed, 47 insertions, 0 deletions
diff --git a/main/tzdata/0001-posixtz-fix-up-lseek.patch b/main/tzdata/0001-posixtz-fix-up-lseek.patch
new file mode 100644
index 000000000..c5b0c74a0
--- /dev/null
+++ b/main/tzdata/0001-posixtz-fix-up-lseek.patch
@@ -0,0 +1,47 @@
+diff --git a/posixtz.c b/posixtz.c
+index 141cca1..604a53d 100644
+--- a/posixtz-0.3/posixtz.c
++++ b/posixtz-0.3/posixtz.c
+@@ -25,18 +25,19 @@
+
+ char *posix_tz(const char *filename)
+ {
+- int fd, r;
++ FILE *f;
++ size_t r;
+ static char buf[TZ_BUFLEN];
+ char *p = NULL;
+- fd = open(filename, O_RDONLY);
+- if (fd < 0)
++ f = fopen(filename, "r");
++ if (f == NULL)
+ return NULL;
+
+- r = read(fd, buf, TZ_BUFLEN);
++ r = fread(buf, 1, TZ_BUFLEN, f);
+ if (r != TZ_BUFLEN
+ || strncmp(buf, "TZif", 4) != 0
+ || (unsigned char)buf[4] < 2
+- || lseek(fd, -TZ_BUFLEN, SEEK_END) < 0
++ || fseek(f, -TZ_BUFLEN, SEEK_END) < 0
+ )
+ goto ERROR;
+
+@@ -50,7 +51,7 @@ char *posix_tz(const char *filename)
+ ** (with nothing between the newlines if there is no POSIX representation for
+ ** such instants).
+ */
+- r = read(fd, buf, TZ_BUFLEN);
++ r = fread(buf, 1, TZ_BUFLEN, f);
+ if (r <= 0 || buf[--r] != '\n')
+ goto ERROR;
+ buf[r] = 0;
+@@ -61,7 +62,7 @@ char *posix_tz(const char *filename)
+ }
+ } /* else ('\n' not found): p remains NULL */
+ ERROR:
+- close(fd);
++ fclose(f);
+ return p;
+ }
+