[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] Re: [PATCH] Replace strcmp() by strncmp()
From: |
Jan Kiszka |
Subject: |
[Qemu-devel] Re: [PATCH] Replace strcmp() by strncmp() |
Date: |
Tue, 27 Jan 2009 10:28:55 +0100 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686 (x86_64); de; rv:1.8.1.12) Gecko/20080226 SUSE/2.0.0.12-1.1 Thunderbird/2.0.0.12 Mnenhy/0.7.5.666 |
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
- [Qemu-devel] [PATCH] Random MAC address option, Pavel Vasilyev, 2009/01/26
- [Qemu-devel] [PATCH] Replace strcmp() by strncmp(), Pavel Vasilyev, 2009/01/26
- [Qemu-devel] Re: [PATCH] Replace strcmp() by strncmp(),
Jan Kiszka <=
- Re: [Qemu-devel] [PATCH] Random MAC address option, malc, 2009/01/26
- Re: [Qemu-devel] [PATCH] Random MAC address option, Kevin Wolf, 2009/01/27
- Re: [Qemu-devel] [PATCH] Random MAC address option, Riku Voipio, 2009/01/27
- Re: [Qemu-devel] [PATCH] Random MAC address option, Paul Brook, 2009/01/27