From: Jan Kiszka <jan.kiszka@siemens.com>
To: pavel@pavlinux.ru
Cc: qemu-devel@nongnu.org
Subject: [Qemu-devel] Re: [PATCH] Replace strcmp() by strncmp()
Date: Tue, 27 Jan 2009 10:28:55 +0100 [thread overview]
Message-ID: <497ED3D7.7000703@siemens.com> (raw)
In-Reply-To: <200901270334.14108.pavel@pavlinux.ru>
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
next prev parent reply other threads:[~2009-01-27 9:28 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-01-27 0:13 [Qemu-devel] [PATCH] Random MAC address option Pavel Vasilyev
2009-01-27 0:34 ` [Qemu-devel] [PATCH] Replace strcmp() by strncmp() Pavel Vasilyev
2009-01-27 9:28 ` Jan Kiszka [this message]
2009-01-27 20:49 ` [Qemu-devel] " Pavel Vasilyev
2009-01-27 21:20 ` Pavel Vasilyev
2009-01-27 0:57 ` [Qemu-devel] [PATCH] Random MAC address option malc
2009-01-27 10:05 ` Kevin Wolf
2009-01-27 10:15 ` Riku Voipio
2009-01-27 10:25 ` Daniel P. Berrange
2009-01-27 14:28 ` Ian Jackson
2009-01-27 20:51 ` Pavel Vasilyev
2009-01-27 16:33 ` Paul Brook
2009-01-27 16:47 ` Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=497ED3D7.7000703@siemens.com \
--to=jan.kiszka@siemens.com \
--cc=pavel@pavlinux.ru \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).