summaryrefslogtreecommitdiff
path: root/libstore
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1996-07-19 20:23:20 +0000
committerMiles Bader <miles@gnu.org>1996-07-19 20:23:20 +0000
commite964858b3d42538ba339325e8f19d3f3365a244f (patch)
treecf8499d95f5a436b6bd1e97c33308a4f0c32ae46 /libstore
parentee777fc3c34092f5e8f620ba22df2dd8cc6e5be3 (diff)
Deal with NAME_LENGTH being 0.
Diffstat (limited to 'libstore')
-rw-r--r--libstore/decode.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/libstore/decode.c b/libstore/decode.c
index cf169d02..5231b33d 100644
--- a/libstore/decode.c
+++ b/libstore/decode.c
@@ -58,19 +58,24 @@ store_std_leaf_decode (struct store_enc *enc,
|| enc->cur_data + name_len + misc_len > enc->data_len)
return EINVAL;
- if (enc->data[enc->cur_data + name_len - 1] != '\0')
+ if (name_len > 0 && enc->data[enc->cur_data + name_len - 1] != '\0')
return EINVAL; /* Name not terminated. */
misc = malloc (misc_len);
if (! misc)
return ENOMEM;
- name = strdup (enc->data + enc->cur_data);
- if (! name)
+ if (name_len > 0)
{
- free (misc);
- return ENOMEM;
+ name = strdup (enc->data + enc->cur_data);
+ if (! name)
+ {
+ free (misc);
+ return ENOMEM;
+ }
}
+ else
+ name = 0;
/* Read encoded ports (be careful to deallocate this if we barf). */
port = enc->ports[enc->cur_port++];
@@ -113,7 +118,8 @@ store_std_leaf_decode (struct store_enc *enc,
{
mach_port_deallocate (mach_task_self (), port);
free (misc);
- free (name);
+ if (name)
+ free (name);
}
else
{