New submission from Christian Heimes: 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. ---------- keywords: easy messages: 170521 nosy: christian.heimes priority: normal severity: normal status: open title: Unchecked return value of I/O functions type: behavior versions: Python 2.7, Python 3.2, Python 3.3 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15948> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com