From de1f1f48d87f26457a5d0c37cc9a2de819bb4a35 Mon Sep 17 00:00:00 2001 From: William Pitcock Date: Thu, 28 Apr 2011 02:52:56 -0500 Subject: main/tzdata: use stdio instead of raw fd operations to work around lseek bug fix #602 --- main/tzdata/0001-posixtz-fix-up-lseek.patch | 47 +++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 main/tzdata/0001-posixtz-fix-up-lseek.patch (limited to 'main/tzdata/0001-posixtz-fix-up-lseek.patch') 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; + } + -- cgit v1.2.3