SUSE / libpulp

libpulp enables live patching in user space applications.
GNU Lesser General Public License v2.1
55 stars 11 forks source link

Fix metadata string szies #78

Closed giulianobelinassi closed 2 years ago

giulianobelinassi commented 3 years ago

In C, a string is defined as an array of characters terminated with the null character '\0' (K&R The C Programming Language, 1988). This means that the length of the empty string, which is 0, has size 1 because it must contain the '\0' character. Induction on the length of the string shows that the size of the string is its length + 1.

This means we should write to the metadata file the string size as being its length + 1 to account for the string size. Else the read strings on trigger may not end which the '\0' character.

Signed-off-by: Giuliano Belinassi gbelinassi@suse.com