hail-devel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [hail patch 1/1] fix hstor crashes
Date: Wed, 7 Jul 2010 18:21:57 -0600	[thread overview]
Message-ID: <20100707182157.5fd492fd@lembas.zaitcev.lan> (raw)

This patch addresses two bugs:

- No parameters to search worked (because character '=' was missing,
  e.g.  delim/ instead of delim=/), and also there were weird truncations
  because prefix can easily be longer than 32 characters.

- If prefix is empty, xmlNodeListGetString returns NULL instead of "",
  thus segfault in strdup. This is not easy to accomplish with Boto,
  but our own httpstor can do it.

Signed-off-by: Pete Zaitcev <zaitcev@redhat.com>

---
 lib/hstor.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

This patch was actually tested on httpstor, I've not switched to hstor
yet, but it seems to apply 100%. There's no sense in fixing httpstor,
I'm going to delete it from tabled soon.

diff --git a/lib/hstor.c b/lib/hstor.c
index 403aca3..5dfff27 100644
--- a/lib/hstor.c
+++ b/lib/hstor.c
@@ -621,13 +621,13 @@ bool hstor_del(struct hstor_client *hstor, const char *bucket, const char *key)
 static GString *append_qparam(GString *str, const char *key, const char *val,
 		       char *arg_char)
 {
-	char *stmp, s[32];
+	char *stmp;
 
 	str = g_string_append(str, arg_char);
 	arg_char[0] = '&';
 
-	sprintf(s, "%s=", key);
 	str = g_string_append(str, key);
+	str = g_string_append(str, "=");
 
 	stmp = huri_field_escape(strdup(val), QUERY_ESCAPE_MASK);
 	str = g_string_append(str, stmp);
@@ -868,7 +868,7 @@ struct hstor_keylist *hstor_keys(struct hstor_client *hstor, const char *bucket,
 		}
 		else if (!_strcmp(node->name, "Prefix")) {
 			xs = xmlNodeListGetString(doc, node->children, 1);
-			keylist->prefix = strdup((char *)xs);
+			keylist->prefix = strdup(xs? (char *)xs: "");
 			xmlFree(xs);
 		}
 		else if (!_strcmp(node->name, "Marker")) {

             reply	other threads:[~2010-07-08  0:21 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-08  0:21 Pete Zaitcev [this message]
2010-07-08  0:44 ` [hail patch 1/1] fix hstor crashes Jeff Garzik

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=20100707182157.5fd492fd@lembas.zaitcev.lan \
    --to=zaitcev@redhat.com \
    --cc=hail-devel@vger.kernel.org \
    --cc=jeff@garzik.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 read-only IMAP folder(s) and NNTP newsgroup(s).