zmanda / amanda

Amanda Network Backup
https://www.zmanda.com/downloads/
Other
214 stars 107 forks source link

Fix file_lock_write #219

Open pkopylov opened 1 year ago

pkopylov commented 1 year ago

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.