open-iscsi / target-isns

Target-isns is an iSNS client for the Linux LIO iSCSI target
GNU General Public License v2.0
16 stars 19 forks source link

Fix string truncation #42

Closed gonzoleeman closed 6 years ago

gonzoleeman commented 6 years ago

The gcc8 compiler complains about snprintf() calls that may be truncated, in the worst case, This mainly effects pathnames. To fix this, rather than making all stack buffers larger, let's use asprintf(), which allocates the strings on the heap and also makes the compiler happy.

gonzoleeman commented 6 years ago

Note: looks like a couple of merge tirds in my pull request, so let me know if you'd like me to recreate it without them.

cvubrugier commented 6 years ago

Thanks @gonzoleeman! I picked your commit as afb8f91, because I was not certain about the merge. I added c3056d3 since I am not sure of the value of the string being NULL when asprintf() fails.