[hail patch 1/1] fix hstor crashes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>

---
 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")) {
--
To unsubscribe from this list: send the line "unsubscribe hail-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Fedora Clound]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux