qulogic/pidgin

Fix incorrect uses of strncpy().
release-2.x.y
2014-03-01, Mark Doliner
8f870b9011c9
Parents 89c89c449595
Children f0861dc04cf3
Fix incorrect uses of strncpy().

I think these aren't actually a problem because prefix is 155 bytes and
filename is 100 bytes, but that's no excuse for writing bad code.

The third argument to strncpy is intended to be the size of the destination
buffer--not the size of the source. We have less error-prone functions now,
let's use them.
--- a/pidgin/win32/untar.c Sat Mar 01 16:35:47 2014 -0800
+++ b/pidgin/win32/untar.c Sat Mar 01 16:58:05 2014 -0800
@@ -395,14 +395,12 @@
name = nbuf;
if ((tblk)->prefix[0])
{
- strncpy(name, (tblk)->prefix, sizeof (tblk)->prefix);
- strcat(name, "/");
- strncat(name + strlen(name), (tblk)->filename,
- sizeof (tblk)->filename);
+ snprintf(name, sizeof(name), "%s/%s",
+ (tblk)->prefix, (tblk)->filename);
}
else
{
- strncpy(name, (tblk)->filename,
+ g_strlcpy(name, (tblk)->filename,
sizeof (tblk)->filename);
}