From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4515 invoked by alias); 9 Oct 2012 20:55:05 -0000 Received: (qmail 3761 invoked by uid 48); 9 Oct 2012 20:54:39 -0000 From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug fortran/54878] New: libgfortran issues found by the Coverity scanner Date: Tue, 09 Oct 2012 20:55:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: fortran X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Changed-Fields: Message-ID: X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated Content-Type: text/plain; charset="UTF-8" MIME-Version: 1.0 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org X-SW-Source: 2012-10/txt/msg00879.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54878 Bug #: 54878 Summary: libgfortran issues found by the Coverity scanner Classification: Unclassified Product: gcc Version: 4.8.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: fortran AssignedTo: unassigned@gcc.gnu.org ReportedBy: burnus@gcc.gnu.org CC: jb@gcc.gnu.org, tkoenig@gcc.gnu.org Sister bug to the FE PR 54599. The coverity scanner found the following (potential) issues in libgfortran. a) io/unix.c: Before calling mkstemps, one should set the umask - otherwise, one might create a world-readable file in /tmp. As the Linux man page put it: The old behavior of creating a file with mode 0666 may be a security risk, especially since other UNIX flavors use 0600, and somebody might overlook this detail when porting programs. More generally, the POSIX specification of mkstemp() does not say anything about file modes, so the application should make sure its file mode creation mask (see umask(2)) is set appropriately before calling mkstemp() (and mkostemp()). b) io/unix.c: In fd_to_stream: Return value not checked for fstat (fd, &statbuf); c) io/unit.c's filename_from_unit At (17): Calling function "unpack_filename(char *, char const *, int)" without checking return value (as is done elsewhere 10 out of 12 times). At (18): No check of the return value of "unpack_filename(filename, u->file, u->file_len)". 784 unpack_filename (filename, u->file, u->file_len); 785 return filename; d) generated/iall_i1.c: Unreachable code: 220 len = GFC_DESCRIPTOR_EXTENT(array,dim); 221 if (len <= 0) 222 return; ... 326 if (len <= 0) 327 *dest = 0; e) runtime/bounds.c: index_type count_0 At (3): Comparing "base" to null implies that "base" might be null. 228 if (base) 229 base = GFOR_POINTER_TO_L1 (base, kind); ... CID 732652 (#1 of 1): Dereference after null check (FORWARD_NULL)At (10): Dereferencing null pointer "base". 248 if (*base) 249 result ++; f) io/list_read.c: Unreachable code in nml_query: 2432 p = write_block (dtp, endlen + 3); 2433 goto query_return; 2434 memcpy (p, &nmlend, endlen + 3); /* <<< UNREACHABLE */ Additionally/Hence: the result "p" is never used. g) io/intrinsics.c CID 732515 (#1 of 1): Unchecked return value (CHECKED_RETURN)At (3): Calling function "sseek(stream *, gfc_offset, int)" without checking return value (as is done elsewhere 21 out of 26 times). (Also not checked in io/file_pos.c's st_backspace.) 262 gf_ftell (int unit) ... 269 sseek (u->s, pos, SEEK_CUR); h) io/inquire.c: inquire_via_unit 47 *iqp->exist = (iqp->common.unit >= 0 48 && iqp->common.unit <= GFC_INTEGER_4_HUGE); The latter is ways true as common.unit is of type GFC_INTEGER_4. And some more.