diff options
author | Michael Schroeder <mls@suse.de> | 2013-03-06 15:42:26 +0100 |
---|---|---|
committer | Michael Schroeder <mls@suse.de> | 2013-03-06 15:42:26 +0100 |
commit | 6f2fdbc28eac5f1aa8819242c6506bc3bffb7ebe (patch) | |
tree | 21b1ccb478f92b1156f9f15a0a20e2010a57aaae /src/repopack.h | |
parent | 466ca05eda763db16f2b366038d899e78e3bfefb (diff) | |
download | libsolv-6f2fdbc28eac5f1aa8819242c6506bc3bffb7ebe.tar.gz libsolv-6f2fdbc28eac5f1aa8819242c6506bc3bffb7ebe.tar.bz2 libsolv-6f2fdbc28eac5f1aa8819242c6506bc3bffb7ebe.zip |
fix dataiterator returning random data in some cases
Fixed two issues:
1) iterating over attributes in with vertical storage could return
junk when some other operation paged in some other data.
2) the returned string could also be in the paged area, or also
in tmpspace if stringification was done. We can't simply alloc
memory as this makes things slower, but in most cases the storage
does not matter. So we offer a new function, dataiterator_strdup(),
that makes the kv.str pointer persistent.
WARNING: this commit is an ABI change as it changes the dataiterator
structure. Sorry.
Diffstat (limited to 'src/repopack.h')
-rw-r--r-- | src/repopack.h | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/repopack.h b/src/repopack.h index 81b7b88..d75e61a 100644 --- a/src/repopack.h +++ b/src/repopack.h @@ -164,12 +164,15 @@ data_fetch(unsigned char *dp, KeyValue *kv, Repokey *key) kv->num2 = 0; return data_read_u32(dp, &kv->num); case REPOKEY_TYPE_MD5: + kv->num = 0; /* not stringified yet */ kv->str = (const char *)dp; return dp + SIZEOF_MD5; case REPOKEY_TYPE_SHA1: + kv->num = 0; /* not stringified yet */ kv->str = (const char *)dp; return dp + SIZEOF_SHA1; case REPOKEY_TYPE_SHA256: + kv->num = 0; /* not stringified yet */ kv->str = (const char *)dp; return dp + SIZEOF_SHA256; case REPOKEY_TYPE_BINARY: @@ -180,6 +183,7 @@ data_fetch(unsigned char *dp, KeyValue *kv, Repokey *key) return data_read_ideof(dp, &kv->id, &kv->eof); case REPOKEY_TYPE_DIRSTRARRAY: dp = data_read_ideof(dp, &kv->id, &kv->eof); + kv->num = 0; /* not stringified yet */ kv->str = (const char *)dp; return dp + strlen(kv->str) + 1; case REPOKEY_TYPE_DIRNUMNUMARRAY: |