This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author christian.heimes
Recipients christian.heimes
Date 2012-09-15.15:29:05
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1347722947.26.0.499070360065.issue15948@psf.upfronthosting.co.za>
In-reply-to
Content
Python's C code contains more than 30 lines that don't check the return value of I/O functions like fseek(). A missing check can hide issues like a failing NFS connection.

I've created an (incomplete) list of missing checks with find and grep.

$ find -name '*.c' | sort | xargs egrep '^(\t|\ )*(fopen|fdopen|fread|fseek|fwite|open|read|write|readdir|readlink|lseek|dup|dup2|opendir|fdopendir|closedir|dirfd|readdir|seekdir|scandir|telldir|fcntl|ioctl)\ *\('

./Modules/_ctypes/libffi/src/dlmalloc.c:          read(fd, buf, sizeof(buf)) == sizeof(buf)) {
./Modules/_cursesmodule.c:    fseek(fp, 0, 0);
./Modules/_cursesmodule.c:    fseek(fp, 0, 0);
./Modules/faulthandler.c:        write(thread.fd, thread.header, thread.header_len);
./Modules/getpath.c:    fseek(env_file, 0, SEEK_SET);
./Modules/mmapmodule.c:        lseek(fileno, 0, SEEK_SET);
./Modules/ossaudiodev.c:     ioctl(fd, SNDCTL_DSP_cmd, &arg)
./Modules/posixmodule.c:    ioctl(slave_fd, I_PUSH, "ptem"); /* push ptem */
./Modules/posixmodule.c:    ioctl(slave_fd, I_PUSH, "ldterm"); /* push ldterm */
./Modules/posixmodule.c:    ioctl(slave_fd, I_PUSH, "ttcompat"); /* push ttcompat */
./Modules/_posixsubprocess.c:            fcntl(fd_dir_fd, F_SETFD, old | FD_CLOEXEC);
./Modules/_posixsubprocess.c:            fcntl(p2cread, F_SETFD, old & ~FD_CLOEXEC);
./Modules/_posixsubprocess.c:            fcntl(c2pwrite, F_SETFD, old & ~FD_CLOEXEC);
./Modules/_posixsubprocess.c:            fcntl(errwrite, F_SETFD, old & ~FD_CLOEXEC);
./Modules/signalmodule.c:        write(wakeup_fd, &byte, 1);
./Modules/socketmodule.c:    ioctl(s->sock_fd, FIONBIO, (caddr_t)&block, sizeof(block));
./Modules/socketmodule.c:    ioctl(s->sock_fd, FIONBIO, (unsigned int *)&block);
./Modules/socketmodule.c:    fcntl(s->sock_fd, F_SETFL, delay_flag);
./Modules/zipimport.c:    fseek(fp, -22, SEEK_END);
./Modules/zipimport.c:        fseek(fp, header_offset, 0);  /* Start of file header */
./Modules/zipimport.c:        fseek(fp, header_offset + 8, 0);
./Modules/zipimport.c:        fseek(fp, header_offset + 42, 0);
./Modules/zipimport.c:    fseek(fp, file_offset, 0);
./Modules/zipimport.c:    fseek(fp, file_offset + 26, 0);
./Modules/zlib/gzlib.c:        open(path,
./PC/getpathp.c:    fseek(env_file, 0, SEEK_SET);
./Python/traceback.c:    lseek(fd, 0, 0); /* Reset position */
./Python/traceback.c:    write(fd, buffer, len);
./Python/traceback.c:    write(fd, buffer, len);
./Python/traceback.c:            write(fd, &c, 1);
./Python/traceback.c:        write(fd, "\"", 1);
./Python/traceback.c:        write(fd, "\"", 1);
./Python/traceback.c:    write(fd, "\n", 1);
./Python/traceback.c:            write(fd, "\n", 1);

The missing checks for zipimport.c are already handles by ticket #15897.
History
Date User Action Args
2012-09-15 15:29:07christian.heimessetrecipients: + christian.heimes
2012-09-15 15:29:07christian.heimessetmessageid: <1347722947.26.0.499070360065.issue15948@psf.upfronthosting.co.za>
2012-09-15 15:29:06christian.heimeslinkissue15948 messages
2012-09-15 15:29:05christian.heimescreate