fix hstor crashes
PATCH 1/1 fix hstor crashes
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.
--- 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.
lib/hstor.c +3 -3
@@ -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" )) {
Jeff Garzik
AppliedQuoted 12 lines · Pete Zaitcev
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<[email protected]>
Quoted 7 lines
--- 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.
applied
Check out 'libhail-merge' branch of tabled.git, it should have already fixed up the issues and the delete.