commit ada24b4005504a9cc8035987cf5175940ae568a7
parent 77809fb0cc7c9ff07f0ecd319240c8e3ee2c9528
Author: Russ Cox <rsc@swtch.com>
Date: Sat, 10 May 2008 13:35:19 -0400
misc: array bounds fixes that gcc finds (John Gosset)
Diffstat:
6 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/cmd/eqn/main.c b/src/cmd/eqn/main.c
@@ -7,7 +7,7 @@
char *version = "version Oct 24, 1991";
-char in[MAXLINE]; /* input buffer */
+char in[MAXLINE+1]; /* input buffer */
int noeqn;
char *cmdname;
diff --git a/src/cmd/jpg/readgif.c b/src/cmd/jpg/readgif.c
@@ -351,11 +351,8 @@ skipextension(Header *h)
}
if(hsize>0 && Bread(h->fd, h->buf, hsize) != hsize)
giferror(h, extreaderr);
- if(!hasdata){
- if(h->buf[hsize-1] != 0)
- giferror(h, "ReadGIF: bad extension format");
+ if(!hasdata)
return;
- }
/* loop counter: Application Extension with NETSCAPE2.0 as string and 1 <loop.count> in data */
if(type == 0xFF && hsize==11 && memcmp(h->buf, "NETSCAPE2.0", 11)==0){
diff --git a/src/cmd/tapefs/32vfs.c b/src/cmd/tapefs/32vfs.c
@@ -93,7 +93,7 @@ popdir(Ram *r)
continue;
f = iget(ino);
strncpy(name, dp->name, VNAMELEN);
- name[VNAMELEN+1] = '\0';
+ name[VNAMELEN] = '\0';
f.name = name;
popfile(r, f);
}
diff --git a/src/cmd/tapefs/v10fs.c b/src/cmd/tapefs/v10fs.c
@@ -84,7 +84,7 @@ popdir(Ram *r)
continue;
f = iget(ino);
strncpy(name, dp->name, VNAMELEN);
- name[VNAMELEN+1] = '\0';
+ name[VNAMELEN] = '\0';
f.name = name;
popfile(r, f);
}
diff --git a/src/cmd/tapefs/v6fs.c b/src/cmd/tapefs/v6fs.c
@@ -85,7 +85,7 @@ popdir(Ram *r)
continue;
f = iget(ino);
strncpy(name, dp->name, V6NAMELEN);
- name[V6NAMELEN+1] = '\0';
+ name[V6NAMELEN] = '\0';
f.name = name;
popfile(r, f);
}
diff --git a/src/cmd/troff/t10.c b/src/cmd/troff/t10.c
@@ -75,7 +75,7 @@ void t_ptinit(void)
ics = EM; /* insertion character space */
for (i = 0; i < (NTAB - 1) && DTAB * (i + 1) < TABMASK; i++)
tabtab[i] = DTAB * (i + 1);
- tabtab[NTAB] = 0;
+ tabtab[NTAB-1] = 0;
pl = 11 * INCH; /* paper length */
po = PO; /* page offset */
spacesz = SS;