# HG changeset patch # User Bram Moolenaar # Date 1650201303 -7200 # Node ID f285dd00704e2206a5b4d3c5d3cc29e9e2ff61e4 # Parent 6a015080f04013d11a76d84d6d672ba7bd017320 patch 8.2.4772: old Coverity warning for not checking ftell() return value Commit: https://github.com/vim/vim/commit/3df8f6e353eeaf24bb5fe3769ed07c03791bb58e Author: Bram Moolenaar Date: Sun Apr 17 14:01:51 2022 +0100 patch 8.2.4772: old Coverity warning for not checking ftell() return value Problem: Old Coverity warning for not checking ftell() return value. Solution: Check return value of fseek() and ftell(). diff --git a/src/misc1.c b/src/misc1.c --- a/src/misc1.c +++ b/src/misc1.c @@ -2337,16 +2337,18 @@ get_cmd_output( fd = mch_fopen((char *)tempname, READBIN); # endif - if (fd == NULL) + // Not being able to seek means we can't read the file. + if (fd == NULL + || fseek(fd, 0L, SEEK_END) == -1 + || (len = ftell(fd)) == -1 // get size of temp file + || fseek(fd, 0L, SEEK_SET) == -1) // back to the start { - semsg(_(e_cant_open_file_str), tempname); + semsg(_(e_cannot_read_from_str), tempname); + if (fd != NULL) + fclose(fd); goto done; } - fseek(fd, 0L, SEEK_END); - len = ftell(fd); // get size of temp file - fseek(fd, 0L, SEEK_SET); - buffer = alloc(len + 1); if (buffer != NULL) i = (int)fread((char *)buffer, (size_t)1, (size_t)len, fd); diff --git a/src/version.c b/src/version.c --- a/src/version.c +++ b/src/version.c @@ -747,6 +747,8 @@ static char *(features[]) = static int included_patches[] = { /* Add new patch number below this line */ /**/ + 4772, +/**/ 4771, /**/ 4770,