Received: from eggs.gnu.org ([2001:4830:134:3::10]:34177) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOnpN-0000ab-72 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 09:45:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aOnpJ-0006lb-W0 for qemu-devel@nongnu.org; Thu, 28 Jan 2016 09:45:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:43956) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aOnpJ-0006lS-QE for qemu-devel@nongnu.org; Thu, 28 Jan 2016 09:45:37 -0500 From: Markus Armbruster 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> <56A73E2E.4000906@msgid.tls.msk.ru> <56A9F2F0.5060005@msgid.tls.msk.ru> Date: Thu, 28 Jan 2016 15:45:32 +0100 In-Reply-To: <56A9F2F0.5060005@msgid.tls.msk.ru> (Michael Tokarev's message of "Thu, 28 Jan 2016 13:52:32 +0300") Message-ID: <87si1hiwz7.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain 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: Michael Tokarev Cc: qemu-devel@nongnu.org Michael Tokarev writes: > Ping? Sorry for the delay, I've been focusing on the QAPI queue to the exclusion of pretty much everything else. > 26.01.2016 12:36, Michael Tokarev wrote: >> 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. I forgot to push. Should be there now, but needs a rebase to current master.