The implementation of the function file_lock_write() looks slightly strange. The library functiong_strdup() used inside doesn't consider the length of the duplicated data. However, the size of the data parameter is restricted by the third parameter len, so its value must limit the number of bytes copied during duplication.
That patch corrects the test function inc_counter(), but it looks suspicious to me because it terminates the character value by a zero character instead of checking how the function file_lock_write() works in case the len parameter equals one and a string is not terminated by a zero character.
The implementation of the function
file_lock_write()
looks slightly strange. The library functiong_strdup()
used inside doesn't consider the length of the duplicated data. However, the size of thedata
parameter is restricted by the third parameterlen
, so its value must limit the number of bytes copied during duplication.That patch corrects the test function
inc_counter()
, but it looks suspicious to me because it terminates the character value by a zero character instead of checking how the functionfile_lock_write()
works in case thelen
parameter equals one and a string is not terminated by a zero character.