misc: array bounds fixes that gcc finds (John Gosset)

This commit is contained in:
Russ Cox 2008-05-10 13:35:19 -04:00
parent 77809fb0cc
commit ada24b4005
6 changed files with 6 additions and 9 deletions

View file

@ -7,7 +7,7 @@
char *version = "version Oct 24, 1991"; char *version = "version Oct 24, 1991";
char in[MAXLINE]; /* input buffer */ char in[MAXLINE+1]; /* input buffer */
int noeqn; int noeqn;
char *cmdname; char *cmdname;

View file

@ -351,11 +351,8 @@ skipextension(Header *h)
} }
if(hsize>0 && Bread(h->fd, h->buf, hsize) != hsize) if(hsize>0 && Bread(h->fd, h->buf, hsize) != hsize)
giferror(h, extreaderr); giferror(h, extreaderr);
if(!hasdata){ if(!hasdata)
if(h->buf[hsize-1] != 0)
giferror(h, "ReadGIF: bad extension format");
return; return;
}
/* loop counter: Application Extension with NETSCAPE2.0 as string and 1 <loop.count> in data */ /* 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){ if(type == 0xFF && hsize==11 && memcmp(h->buf, "NETSCAPE2.0", 11)==0){

View file

@ -93,7 +93,7 @@ popdir(Ram *r)
continue; continue;
f = iget(ino); f = iget(ino);
strncpy(name, dp->name, VNAMELEN); strncpy(name, dp->name, VNAMELEN);
name[VNAMELEN+1] = '\0'; name[VNAMELEN] = '\0';
f.name = name; f.name = name;
popfile(r, f); popfile(r, f);
} }

View file

@ -84,7 +84,7 @@ popdir(Ram *r)
continue; continue;
f = iget(ino); f = iget(ino);
strncpy(name, dp->name, VNAMELEN); strncpy(name, dp->name, VNAMELEN);
name[VNAMELEN+1] = '\0'; name[VNAMELEN] = '\0';
f.name = name; f.name = name;
popfile(r, f); popfile(r, f);
} }

View file

@ -85,7 +85,7 @@ popdir(Ram *r)
continue; continue;
f = iget(ino); f = iget(ino);
strncpy(name, dp->name, V6NAMELEN); strncpy(name, dp->name, V6NAMELEN);
name[V6NAMELEN+1] = '\0'; name[V6NAMELEN] = '\0';
f.name = name; f.name = name;
popfile(r, f); popfile(r, f);
} }

View file

@ -75,7 +75,7 @@ void t_ptinit(void)
ics = EM; /* insertion character space */ ics = EM; /* insertion character space */
for (i = 0; i < (NTAB - 1) && DTAB * (i + 1) < TABMASK; i++) for (i = 0; i < (NTAB - 1) && DTAB * (i + 1) < TABMASK; i++)
tabtab[i] = DTAB * (i + 1); tabtab[i] = DTAB * (i + 1);
tabtab[NTAB] = 0; tabtab[NTAB-1] = 0;
pl = 11 * INCH; /* paper length */ pl = 11 * INCH; /* paper length */
po = PO; /* page offset */ po = PO; /* page offset */
spacesz = SS; spacesz = SS;