Commit a3d2ec3d authored by Julian Wiesener's avatar Julian Wiesener

fix off by one

parent b0ffe9a6
Pipeline #15 skipped
......@@ -152,7 +152,7 @@ static int vtstor_set_key(struct vmod_vtstor_vtstor *vmi, struct vtstor_node *no
{
CHECK_OBJ_NOTNULL(vmi, VMOD_VTSTOR_VTSTOR_MAGIC);
CHECK_OBJ_NOTNULL(node, VMOD_VTSTOR_NODE_MAGIC);
size_t size = strlen(s);
size_t size = strlen(s) + 1;
if(size > vmi->key_max)
return 0;
if(node->key) {
......@@ -163,7 +163,7 @@ static int vtstor_set_key(struct vmod_vtstor_vtstor *vmi, struct vtstor_node *no
vmi->dealloc(vmi, &node->key);
}
node->key_capacity = vmi->alloc(vmi, size, &node->key);
if(node->key_capacity)
if(node->key_capacity >= size)
strcpy(node->key, s);
return node->key_capacity;
}
......@@ -172,7 +172,7 @@ static int vtstor_set_value(struct vmod_vtstor_vtstor *vmi, struct vtstor_node *
{
CHECK_OBJ_NOTNULL(vmi, VMOD_VTSTOR_VTSTOR_MAGIC);
CHECK_OBJ_NOTNULL(node, VMOD_VTSTOR_NODE_MAGIC);
size_t size = strlen(s);
size_t size = strlen(s) + 1;
if(size > vmi->value_max)
return 0;
if(node->value) {
......@@ -183,7 +183,7 @@ static int vtstor_set_value(struct vmod_vtstor_vtstor *vmi, struct vtstor_node *
vmi->dealloc(vmi, &node->value);
}
node->value_capacity = vmi->alloc(vmi, size, &node->value);
if(node->value_capacity)
if(node->value_capacity >= size)
strcpy(node->value, s);
return node->value_capacity;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment