The following commit has been merged in the master branch:
commit 142c6b659c7478498d5c41b4c3d3ed1928b985a1
Author: Guillem Jover <[email protected]>
Date: Sun Nov 13 19:56:28 2011 +0100
libdpkg: Use m_strndup() instead of StoC()
diff --git a/lib/dpkg/tarfn.c b/lib/dpkg/tarfn.c
index ead7d34..90d5071 100644
--- a/lib/dpkg/tarfn.c
+++ b/lib/dpkg/tarfn.c
@@ -79,23 +79,6 @@ OtoM(const char *s, int size)
return n;
}
-/**
- * Convert a string block to C NUL-terminated string.
- */
-static char *
-StoC(const char *s, int size)
-{
- int len;
- char *str;
-
- len = strnlen(s, size);
- str = m_malloc(len + 1);
- memcpy(str, s, len);
- str[len] = '\0';
-
- return str;
-}
-
static char *
get_prefix_name(struct tar_header *h)
{
@@ -193,8 +176,8 @@ tar_header_decode(struct tar_header *h, struct tar_entry *d)
if (d->format == tar_format_ustar && h->prefix[0] != '\0')
d->name = get_prefix_name(h);
else
- d->name = StoC(h->name, sizeof(h->name));
- d->linkname = StoC(h->linkname, sizeof(h->linkname));
+ d->name = m_strndup(h->name, sizeof(h->name));
+ d->linkname = m_strndup(h->linkname, sizeof(h->linkname));
d->stat.mode = get_unix_mode(h);
d->size = (off_t)OtoM(h->size, sizeof(h->size));
d->mtime = (time_t)OtoM(h->mtime, sizeof(h->mtime));
--
dpkg's main repository
--
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]