Received: from eggs.gnu.org ([2001:4830:134:3::10]:48694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO03Z-0008PJ-Vz for qemu-devel@nongnu.org; Tue, 26 Jan 2016 04:37:02 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO03V-000102-0r for qemu-devel@nongnu.org; Tue, 26 Jan 2016 04:37:01 -0500 Received: from isrv.corpit.ru ([86.62.121.231]:49247) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO03U-0000qi-QY for qemu-devel@nongnu.org; Tue, 26 Jan 2016 04:36:56 -0500 References: <56920EC7.6090109@msgid.tls.msk.ru> <20160111075914.GA28466@olga> <87wprfqj8t.fsf@blackfin.pond.sub.org> <1786291473.38.33445737-8c34-4632-b55f-f565652bb5d3.open-xchange@webmail.proxmox.com> <87h9iirdms.fsf@blackfin.pond.sub.org> <1388889179.80.33445737-8c34-4632-b55f-f565652bb5d3.open-xchange@webmail.proxmox.com> <877fjepwo9.fsf@blackfin.pond.sub.org> <20160113080958.GA18934@olga> <87io2rnir4.fsf@blackfin.pond.sub.org> <20160118133819.GA29453@olga> <87oacjklvb.fsf@blackfin.pond.sub.org> From: Michael Tokarev Message-ID: <56A73E2E.4000906@msgid.tls.msk.ru> Date: Tue, 26 Jan 2016 12:36:46 +0300 MIME-Version: 1.0 In-Reply-To: <87oacjklvb.fsf@blackfin.pond.sub.org> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit 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: Markus Armbruster Cc: qemu-devel@nongnu.org 18.01.2016 17:23, Markus Armbruster wrote: [...] > Applied to my monitor-next with these tweaks: > > diff --git a/hmp.c b/hmp.c > index 8be03df..9c571f5 100644 > --- a/hmp.c > +++ b/hmp.c > @@ -1739,7 +1739,7 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) > keyname_len = separator ? separator - keys : strlen(keys); > > /* Be compatible with old interface, convert user inputted "<" */ > - if (!strncmp(keys, "<", 1) && keyname_len == 1) { > + if (keys[0] == '<' && keyname_len == 1) { > keys = "less"; > keyname_len = 4; > } > @@ -1758,7 +1758,8 @@ void hmp_sendkey(Monitor *mon, const QDict *qdict) > if (strstart(keys, "0x", NULL)) { > char *endp; > int value = strtoul(keys, &endp, 0); > - if (*endp != '\0' && *endp != '-') { > + assert(endp <= keys + keyname_len); > + if (endp != keys + keyname_len) { > goto err_out; > } > keylist->value->type = KEY_VALUE_KIND_NUMBER; Marcus, where's your monitor-next branch? Repository at git://repo.or.cz/qemu/armbru.git , monitor-next branch does not contain this change, last commit to hmp.c dated Sep-8. Thanks, /mjt