From patchwork Sat Dec 13 22:09:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 4238 Received: (qmail 7645 invoked by alias); 13 Dec 2014 22:10:15 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 7633 invoked by uid 89); 13 Dec 2014 22:10:14 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f51.google.com Received: from mail-pa0-f51.google.com (HELO mail-pa0-f51.google.com) (209.85.220.51) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Sat, 13 Dec 2014 22:10:13 +0000 Received: by mail-pa0-f51.google.com with SMTP id ey11so9442182pad.38 for ; Sat, 13 Dec 2014 14:10:11 -0800 (PST) X-Received: by 10.70.87.133 with SMTP id ay5mr37654229pdb.75.1418508611874; Sat, 13 Dec 2014 14:10:11 -0800 (PST) Received: from sspiff.org (173-13-178-50-sfba.hfc.comcastbusiness.net. [173.13.178.50]) by mx.google.com with ESMTPSA id pc8sm5053838pdb.54.2014.12.13.14.10.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 13 Dec 2014 14:10:11 -0800 (PST) Received: by sspiff.org (sSMTP sendmail emulation); Sat, 13 Dec 2014 14:09:18 -0800 From: Doug Evans To: gdb-patches@sourceware.org, brobecker@adacore.com Subject: [COMMITTED PATCH] Fix off-by-one error in make_hex_string. Date: Sat, 13 Dec 2014 14:09:18 -0800 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes Hi. I noticed a failure in py-objfile.exp: python print (objfile.build_id) ../../to-push/gdb/common/common-utils.c:139: internal-error: xsnprintf: Assertion `ret < size' failed. It's just an off-by-one error in make_hex_string. The size argument to xsnprintf must include the trailing nul, but the result does not include it. 2014-12-13 Doug Evans * utils.c (make_hex_string): Fix off-by-one error. diff --git a/gdb/utils.c b/gdb/utils.c index ea2b18a..47adb67 100644 --- a/gdb/utils.c +++ b/gdb/utils.c @@ -1124,7 +1124,7 @@ make_hex_string (const gdb_byte *data, size_t length) p = result; for (i = 0; i < length; ++i) - p += xsnprintf (p, 2, "%02x", data[i]); + p += xsnprintf (p, 3, "%02x", data[i]); *p = '\0'; return result; }