From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LRkFe-0003TQ-FD for qemu-devel@nongnu.org; Tue, 27 Jan 2009 04:28:58 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LRkFc-0003T7-GM for qemu-devel@nongnu.org; Tue, 27 Jan 2009 04:28:57 -0500 Received: from [199.232.76.173] (port=45099 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LRkFc-0003T3-AY for qemu-devel@nongnu.org; Tue, 27 Jan 2009 04:28:56 -0500 Received: from gecko.sbs.de ([194.138.37.40]:17467) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LRkFb-0007hH-NY for qemu-devel@nongnu.org; Tue, 27 Jan 2009 04:28:56 -0500 Message-ID: <497ED3D7.7000703@siemens.com> Date: Tue, 27 Jan 2009 10:28:55 +0100 From: Jan Kiszka MIME-Version: 1.0 References: <200901270313.26331.pavel@pavlinux.ru> <200901270334.14108.pavel@pavlinux.ru> In-Reply-To: <200901270334.14108.pavel@pavlinux.ru> Content-Type: text/plain; charset=ISO-8859-15 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH] Replace strcmp() by strncmp() Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: pavel@pavlinux.ru Cc: qemu-devel@nongnu.org Pavel Vasilyev wrote: > Possible SIGSEGV I would suggest studying some strncmp implementation and also thinking about the case that 'device' is, say, "nics"... Jan > > Index: net.c > =================================================================== > --- net.c (revision 6463) > +++ net.c (working copy) > @@ -1568,7 +1586,7 @@ > if (get_param_value(buf, sizeof(buf), "name", p)) { > name = strdup(buf); > } > - if (!strcmp(device, "nic")) { > + if (!strncmp(device, "nic", 3)) { > NICInfo *nd; > uint8_t *macaddr; > > @@ -1601,13 +1630,13 @@ > vlan->nb_guest_devs++; > ret = 0; > } else > - if (!strcmp(device, "none")) { > + if (!strncmp(device, "none", 4)) { > /* does nothing. It is needed to signal that no network cards > are wanted */ > ret = 0; > } else > #ifdef CONFIG_SLIRP > - if (!strcmp(device, "user")) { > + if (!strncmp(device, "user", 4)) { > if (get_param_value(buf, sizeof(buf), "hostname", p)) { > pstrcpy(slirp_hostname, sizeof(slirp_hostname), buf); > } > @@ -1622,7 +1651,7 @@ > } else > #endif > #ifdef _WIN32 > - if (!strcmp(device, "tap")) { > + if (!strncmp(device, "tap", 3)) { > char ifname[64]; > if (get_param_value(ifname, sizeof(ifname), "ifname", p) <= 0) { > fprintf(stderr, "tap: no interface name\n"); > @@ -1633,7 +1662,7 @@ > } else > #elif defined (_AIX) > #else > - if (!strcmp(device, "tap")) { > + if (!strncmp(device, "tap", 3)) { > char ifname[64]; > char setup_script[1024], down_script[1024]; > int fd; > > -- Siemens AG, Corporate Technology, CT SE 2 Corporate Competence Center Embedded Linux