From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) by sourceware.org (Postfix) with ESMTPS id 7FF1B386100D for ; Tue, 30 Jun 2020 23:32:02 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 7FF1B386100D Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNVWFi138165 for ; Tue, 30 Jun 2020 23:32:01 GMT Received: from userp3020.oracle.com (userp3020.oracle.com [156.151.31.79]) by userp2130.oracle.com with ESMTP id 31ywrbnkux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 30 Jun 2020 23:32:01 +0000 Received: from pps.filterd (userp3020.oracle.com [127.0.0.1]) by userp3020.oracle.com (8.16.0.42/8.16.0.42) with SMTP id 05UNMYto051963 for ; Tue, 30 Jun 2020 23:32:01 GMT Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userp3020.oracle.com with ESMTP id 31xfvt5uwr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Tue, 30 Jun 2020 23:32:01 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id 05UNW0dI001256 for ; Tue, 30 Jun 2020 23:32:00 GMT Received: from loom.srvr.nix (/81.187.191.129) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Tue, 30 Jun 2020 23:32:00 +0000 From: Nick Alcock To: binutils@sourceware.org Subject: [PATCH 12/59] libctf, types: ints, floats and typedefs with no name are invalid Date: Wed, 1 Jul 2020 00:30:59 +0100 Message-Id: <20200630233146.338613-13-nick.alcock@oracle.com> X-Mailer: git-send-email 2.27.0.247.g3dff7de930 In-Reply-To: <20200630233146.338613-1-nick.alcock@oracle.com> References: <20200630233146.338613-1-nick.alcock@oracle.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 adultscore=0 spamscore=0 phishscore=0 malwarescore=0 mlxlogscore=913 bulkscore=0 mlxscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300162 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9668 signatures=668680 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 bulkscore=0 spamscore=0 mlxlogscore=919 clxscore=1015 cotscore=-2147483648 priorityscore=1501 lowpriorityscore=0 malwarescore=0 mlxscore=0 adultscore=0 suspectscore=1 impostorscore=0 phishscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2004280000 definitions=main-2006300163 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, SPF_PASS, TXREP, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: binutils@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 30 Jun 2020 23:32:03 -0000 Report them as such, rather than letting ctf_decl_sprintf wrongly conclude that the printing of zero characters means we are out of memory. libctf/ * ctf-types.c (ctf_type_aname): Return ECTF_CORRUPT if ints, floats or typedefs have no name. Fix comment typo. --- libctf/ctf-types.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libctf/ctf-types.c b/libctf/ctf-types.c index f5a1fc0ae12..db42b9e8a90 100644 --- a/libctf/ctf-types.c +++ b/libctf/ctf-types.c @@ -316,7 +316,7 @@ ctf_id_t ctf_lookup_by_rawhash (ctf_file_t *fp, ctf_names_t *np, const char *nam return id; } -/* Lookup the given type ID and return its name as a new dynamcally-allocated +/* Lookup the given type ID and return its name as a new dynamically-allocated string. */ char * @@ -379,6 +379,15 @@ ctf_type_aname (ctf_file_t *fp, ctf_id_t type) case CTF_K_INTEGER: case CTF_K_FLOAT: case CTF_K_TYPEDEF: + /* Integers, floats, and typedefs must always be named types. */ + + if (name[0] == '\0') + { + ctf_set_errno (fp, ECTF_CORRUPT); + ctf_decl_fini (&cd); + return NULL; + } + ctf_decl_sprintf (&cd, "%s", name); break; case CTF_K_POINTER: -- 2.27.0.247.g3dff7de930