All of lore.kernel.org
 help / color / mirror / Atom feed
From: Milan Broz <mbroz@redhat.com>
To: lvm-devel@redhat.com
Subject: [PATCH] dmeventd protocol versioning mechanism
Date: Mon, 21 Mar 2011 15:13:13 +0100	[thread overview]
Message-ID: <4D875CF9.5020100@redhat.com> (raw)
In-Reply-To: <877hbunlu9.fsf@twilight.int.mornfall.net.>

On 03/20/2011 11:10 AM, Petr Rockai wrote:
+/*
+ * You can (and have to) call this in place of
+ * daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0)
+ * -- this call will parse the version reply from dmeventd, in addition to
+ * above call. It is not safe to call this at any other place in the
+ * protocol.
+ */
+int dm_event_get_version(struct dm_event_fifos *fifos, int *version) {
+ char *p;
+ struct dm_event_daemon_message msg = { 0, 0, NULL };
+
+ if (daemon_talk(fifos, &msg, DM_EVENT_CMD_HELLO, NULL, NULL, 0, 0))
+ return 0;
+ p = msg.data;
+ *version = 0;
+
+ p = strchr(p, ' ') + 1; /* Message ID */
+ p = strchr(p, ' ') + 1; /* HELLO */
+ p = strchr(p, ' '); /* HELLO, once more */


Is this safe? I think it will segfault on malformed reply (no spaces).
strchr(NULL, ...)


Milan



  reply	other threads:[~2011-03-21 14:13 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-20 10:10 [PATCH] dmeventd protocol versioning mechanism Petr Rockai
2011-03-21 14:13 ` Milan Broz [this message]
2011-03-21 15:32   ` Petr Rockai
2011-03-21 15:45     ` Milan Broz

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=4D875CF9.5020100@redhat.com \
    --to=mbroz@redhat.com \
    --cc=lvm-devel@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.