/pidgin/main: 8f870b9011c9: Fix incorrect uses of strncpy().
Mark Doliner
mark at kingant.net
Wed Oct 22 10:20:23 EDT 2014
Changeset: 8f870b9011c948fb2a73fa399c9d25b4379a8807
Author: Mark Doliner <mark at kingant.net>
Date: 2014-03-01 16:58 -0800
Branch: release-2.x.y
URL: https://hg.pidgin.im/pidgin/main/rev/8f870b9011c9
Description:
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.
diffstat:
pidgin/win32/untar.c | 8 +++-----
1 files changed, 3 insertions(+), 5 deletions(-)
diffs (21 lines):
diff --git a/pidgin/win32/untar.c b/pidgin/win32/untar.c
--- a/pidgin/win32/untar.c
+++ b/pidgin/win32/untar.c
@@ -395,14 +395,12 @@ static int untar_block(Uchar_t *blk) {
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);
}
More information about the Commits
mailing list