GNOME Bugzilla – Bug 60933
Array overrun
Last modified: 2004-12-22 21:47:04 UTC
Building mc/4.5.54 for SGI IRIX 6.5, I noticed a couple places where the code was writing off the end of it's arrays. Here's a fix: --- ./vfs/cpio.c Fri Mar 9 02:30:04 2001 +++ ../mc-4.5.54/./vfs/cpio.c Fri Sep 21 16:27:26 2001 @@ -300,7 +300,7 @@ if((len = mc_read(super->u.cpio.fd, (void *)buf, HEAD_LENGTH)) < HEAD_LENGTH) return STATUS_EOF; CPIO_POS(super) += len; - buf[HEAD_LENGTH + 1] = 0; + buf[HEAD_LENGTH] = NULL; if(sscanf((void *)buf, "070707%6lo%6lo%6lo%6lo%6lo%6lo%6lo%11lo%6lo%11lo", &hd.c_dev, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid, @@ -348,7 +348,7 @@ if((len = mc_read(super->u.cpio.fd, buf, HEAD_LENGTH)) < HEAD_LENGTH) return STATUS_EOF; CPIO_POS(super) += len; - buf[HEAD_LENGTH + 1] = 0; + buf[HEAD_LENGTH] = '\0'; if(sscanf(buf, "%6ho%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx%8lx", &hd.c_magic, &hd.c_ino, &hd.c_mode, &hd.c_uid, &hd.c_gid,
Replace NULL with 0. Applied to CVS. Thank you! Please email your bug reports and patches to mc-devel@gnome.org Regards, Andrew V. Samoilov.
Close this?