summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-18 04:15:56 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-18 04:15:56 +0300
commitbef4be688de3b29fe62d10bf723ad888111853aa (patch)
tree19670956fe3e9f2a03956ff8b6f9ec7e1c6e8475
parent1abd80f9c2a6d746bdc12d708210b69680d7e1ca (diff)
downloadlibrpm-tizen-bef4be688de3b29fe62d10bf723ad888111853aa.tar.gz
librpm-tizen-bef4be688de3b29fe62d10bf723ad888111853aa.tar.bz2
librpm-tizen-bef4be688de3b29fe62d10bf723ad888111853aa.zip
Dont assume \0 terminated strings in rpmstrPoolPut()
- Before this, the slen argument was only good for avoiding an extra strlen() but being able to handle shove and lookup partial strings without local copy+modify in callers is handy, this is one of the prerequisites for that.
-rw-r--r--rpmio/rpmstrpool.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/rpmio/rpmstrpool.c b/rpmio/rpmstrpool.c
index c0fb4bcf4..dc208a622 100644
--- a/rpmio/rpmstrpool.c
+++ b/rpmio/rpmstrpool.c
@@ -251,7 +251,7 @@ void rpmstrPoolUnfreeze(rpmstrPool pool)
static rpmsid rpmstrPoolPut(rpmstrPool pool, const char *s, size_t slen, unsigned int hash)
{
- const char *t = NULL;
+ char *t = NULL;
size_t ssize = slen + 1;
if (ssize > pool->data_alloced - pool->data_size) {
@@ -272,7 +272,8 @@ static rpmsid rpmstrPoolPut(rpmstrPool pool, const char *s, size_t slen, unsigne
pool->offs_alloced * sizeof(*pool->offs));
}
- t = memcpy(pool->data + pool->data_size, s, ssize);
+ t = memcpy(pool->data + pool->data_size, s, slen);
+ t[slen] = '\0';
pool->offs[pool->offs_size] = pool->data_size;
pool->data_size += ssize;