usr.sbin/makefs/cd9660/cd9660_debug.c CID 975346 (#1 of 2): Ignoring number of bytes read (CHECKED_RETURN) 3. check_return: fread(void * restrict, size_t, size_t, FILE * restrict) returns the number of bytes read, but it is ignored. 208 fread(((unsigned char*)&pttemp) + 8, 1, pttemp.length[0], fd); CID 975345 (#1 of 1): Ignoring number of bytes read (CHECKED_RETURN) 2. check_return: fread(void * restrict, size_t, size_t, FILE * restrict) returns the number of bytes read, but it is ignored. 238 fread(buf, 1, CD9660_SECTOR_SIZE, fd); --------------- Source analysis: Indeed one should check for complete read success. Just above the fread() calls, fseeko() failure leads to err(): 200 if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1) 201 err(1, "fseeko"); 236 if (fseeko(fd, CD9660_SECTOR_SIZE * sector, SEEK_SET) == -1) 237 err(1, "fseeko"); --------------- Remedy proposal: One should distinguish between EOF and error. - fread(((unsigned char*)&pttemp) + 8, 1, pttemp.length[0], fd); + if (fread(((unsigned char*)&pttemp) + 8, 1, pttemp.length[0], + fd) != pttemp.length[0]) { + if (feof(fd)) + err(1, "EOF on fread"); + err(1, "Error on fread"); + } - fread(buf, 1, CD9660_SECTOR_SIZE, fd); + if (fread(buf, 1, CD9660_SECTOR_SIZE, fd) != + CD9660_SECTOR_SIZE) { + if (feof(fd)) + err(1, "EOF on fread"); + err(1, "Error on fread"); + }
Bulk taking makefs bugs.
Releasing bugs back to the pool.