Received: from eggs.gnu.org ([2001:4830:134:3::10]:43410) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHXZx-0000AP-3W for qemu-devel@nongnu.org; Fri, 08 Jan 2016 08:59:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHXZt-0001te-TI for qemu-devel@nongnu.org; Fri, 08 Jan 2016 08:59:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34647) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHXZt-0001tT-OE for qemu-devel@nongnu.org; Fri, 08 Jan 2016 08:59:41 -0500 Date: Fri, 8 Jan 2016 19:29:31 +0530 (IST) From: P J P In-Reply-To: <20160108130251.GA17847@olga> Message-ID: References: <20160108091949.GA14724@olga> <20160108130251.GA17847@olga> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Subject: Re: [Qemu-devel] [PATCH] hmp: avoid redundant null termination of buffer List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Wolfgang Bumiller Cc: qemu-devel@nongnu.org, Ling Liu +-- On Fri, 8 Jan 2016, Wolfgang Bumiller wrote --+ | Ah yes, how could I miss that. Maybe just add a min() around the | keyname_len computation? | | - keyname_len = separator ? separator - keys : strlen(keys); | + keyname_len = MIN(sizeof(keyname_buf), separator ? separator - keys : strlen(keys)) Actually, only use for 'keyname_len' is in the subsequent if statement, which IIUC compares the keyname_buf for "<" key. Maybe it could say + if (!strncmp(keyname_buf, "<-", 2)) and remove the 'keyname_len' altogether. -- - P J P 47AF CE69 3A90 54AA 9045 1053 DD13 3D32 FE5B 041F