projects/libpws

changeset 6:1c0e7f79e737

Fix incorrect field size for text fields

The field size should be the string length excluding the terminating null byte
which is there for convenience only when using the C API and not part of the
on-disk format.
author Guido Berhoerster <guido+libpws@berhoerster.name>
date Thu Jan 10 09:35:16 2019 +0100 (2019-01-10)
parents b3fc9f7e2b43
children 7fd61c245bbd
files pws-field.c
line diff
     1.1 --- a/pws-field.c	Thu Jan 10 08:05:32 2019 +0100
     1.2 +++ b/pws-field.c	Thu Jan 10 09:35:16 2019 +0100
     1.3 @@ -199,8 +199,8 @@
     1.4  		return (-1);
     1.5  	}
     1.6  	field->value.text = t;
     1.7 -	field->size = len + 1;
     1.8 -	memcpy(field->value.text, s, field->size);
     1.9 +	field->size = len;
    1.10 +	memcpy(field->value.text, s, len + 1);
    1.11  
    1.12  	return (0);
    1.13  }