zsh-workers
 help / color / mirror / code / Atom feed
* forward: update to fix I sent yesterday
@ 2001-12-15  1:20 Peter Stephenson
  0 siblings, 0 replies; only message in thread
From: Peter Stephenson @ 2001-12-15  1:20 UTC (permalink / raw)
  To: Zsh hackers list


[-- Attachment #0: JohnW@bops.com --]
[-- Type: message/rfc822, Size: 4755 bytes --]

[-- Attachment #1.1: Type: text/plain, Size: 124 bytes --]

I haven't actually changed anything in the fix, but I made a diff so
hopefully that'll be more convenient.
 <<patch.diff>> 

[-- Attachment #1.2: patch.diff --]
[-- Type: application/octet-stream, Size: 2304 bytes --]

diff -urH zsh-4.0.4/Src/exec.c zsh-4.0.5/Src/exec.c
--- zsh-4.0.4/Src/exec.c	Wed Oct 24 06:16:32 2001
+++ zsh-4.0.5/Src/exec.c	Mon Dec 10 13:33:48 2001
@@ -3470,7 +3470,7 @@
 getfpfunc(char *s, int *ksh)
 {
     char **pp, buf[PATH_MAX];
-    off_t len;
+    off_t len, textlen;
     char *d;
     Eprog r;
     int fd;
@@ -3490,12 +3490,12 @@
 	    if ((len = lseek(fd, 0, 2)) != -1) {
 		d = (char *) zalloc(len + 1);
 		lseek(fd, 0, 0);
-		if (read(fd, d, len) == len) {
+		if ((textlen = read(fd, d, len)) >= 0) {
 		    char *oldscriptname = scriptname;
 
 		    close(fd);
-		    d[len] = '\0';
-		    d = metafy(d, len, META_REALLOC);
+		    d[textlen] = '\0';
+		    d = metafy(d, textlen, META_REALLOC);
 
 		    scriptname = dupstring(s);
 		    r = parse_string(d, 1);
diff -urH zsh-4.0.4/Src/parse.c zsh-4.0.5/Src/parse.c
--- zsh-4.0.4/Src/parse.c	Wed Oct 24 06:16:32 2001
+++ zsh-4.0.5/Src/parse.c	Mon Dec 10 13:23:12 2001
@@ -2405,7 +2405,7 @@
     int fd, v = 0;
     wordcode buf[FD_PRELEN + 1];
 
-    if ((fd = open(name, O_RDONLY)) < 0) {
+    if ((fd = open(name, O_RDONLY | O_BINARY)) < 0) {
 	if (err)
 	    zwarnnam(nam, "can't open zwc file: %s", name, 0);
 	return NULL;
@@ -2542,7 +2542,7 @@
 static int
 build_dump(char *nam, char *dump, char **files, int ali, int map, int flags)
 {
-    int dfd, fd, hlen, tlen, flen, ona = noaliases;
+    int dfd, fd, hlen, tlen, flen, ona = noaliases, textlen;
     LinkList progs;
     char *file;
     Eprog prog;
@@ -2577,9 +2577,8 @@
 	    return 1;
 	}
 	file = (char *) zalloc(flen + 1);
-	file[flen] = '\0';
 	lseek(fd, 0, 0);
-	if (read(fd, file, flen) != flen) {
+	if ((textlen = read(fd, file, flen)) < 0) {
 	    close(fd);
 	    close(dfd);
 	    zfree(file, flen);
@@ -2589,7 +2588,8 @@
 	    return 1;
 	}
 	close(fd);
-	file = metafy(file, flen, META_REALLOC);
+	file[textlen] = '\0';
+	file = metafy(file, textlen, META_REALLOC);
 
 	if (!(prog = parse_string(file, 1)) || errflag) {
 	    errflag = 0;
@@ -3014,7 +3014,7 @@
 	    Patprog *pp;
 	    int np, fd, po = h->npats * sizeof(Patprog);
 
-	    if ((fd = open(file, O_RDONLY)) < 0 ||
+	    if ((fd = open(file, O_RDONLY | O_BINARY)) < 0 ||
 		lseek(fd, ((h->start * sizeof(wordcode)) +
 			   ((fdflags(d) & FDF_OTHER) ? fdother(d) : 0)), 0) < 0) {
 		if (fd >= 0)

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2001-12-15  1:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-12-15  1:20 forward: update to fix I sent yesterday Peter Stephenson

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).