[NCLUG] newbie::Write to superblocks

Yong Sun ysun at gxt.com
Tue Jul 31 16:39:42 MDT 2001


Hey Guys,

I am a programmer in Unix environment, but a newbie on Linux. We just
upgraded our redhat linux from 6.2 to 7.1, so I can access the over 2Gb
files. One run on the system made the superblock damaged. I am not sure
it is from my program, but my sys adm said I am the most likely
candidate. The program is simple like,

int fd = open(afile, O_WRONLY|O_CREAT|O_TRUNC|O_LARGEFILE, 0644);
int n1, n2, n3;
....
off64_t offset = (off64_t) (n1*n2*n3*sizeof(float)); // here
n1*n2*n3*sizeof(float) could overflow
if(lseek64(fd, offset, SEEK_SET) != offset) exit(-1);
write(fd, blablah...);

The argument is that the offset could be a big negative number, so it
seeked to it and it is in superblock...

Is that true? If yes, the file system will have no protection at all!

Thanks,
Yong




More information about the NCLUG mailing list