ref: refs/heads/SuSE-Code-11-Branch
commit a645120d15c7a8e4746013ae4cbb13e92fd07b7c
Author: Michael Schroeder
Date: Fri Sep 25 15:34:26 2009 +0200
- backport allocation fix in repo_solv
---
package/libsatsolver.changes | 5 +++
src/repo_solv.c | 74 +++++++++++++++++++++--------------------
2 files changed, 43 insertions(+), 36 deletions(-)
diff --git a/package/libsatsolver.changes b/package/libsatsolver.changes
index 28f6740..cd756b3 100644
--- a/package/libsatsolver.changes
+++ b/package/libsatsolver.changes
@@ -1,4 +1,9 @@
-------------------------------------------------------------------
+Fri Sep 25 15:33:38 CEST 2009 - mls@suse.de
+
+- backport allocation fix in repo_solv
+
+-------------------------------------------------------------------
Thu Sep 3 15:24:41 CEST 2009 - mls@suse.de
- fix multiversion handling for real (#bnc531899)
diff --git a/src/repo_solv.c b/src/repo_solv.c
index 89bd41e..71a63b8 100644
--- a/src/repo_solv.c
+++ b/src/repo_solv.c
@@ -1017,6 +1017,44 @@ repo_add_solv_parent(Repo *repo, FILE *fp, Repodata *parent)
needchunk = 1;
for(;;)
{
+ /* make sure we have enough room */
+ if (keydepth == 0 || needchunk)
+ {
+ int left = bufend - dp;
+ /* read data chunk to dp */
+ if (data.error)
+ break;
+ if (left < 0)
+ {
+ pool_debug(mypool, SAT_ERROR, "buffer overrun\n");
+ data.error = SOLV_ERROR_EOF;
+ break;
+ }
+ if (left < maxsize)
+ {
+ if (left)
+ memmove(buf, dp, left);
+ l = maxsize - left;
+ if (l < DATA_READ_CHUNK)
+ l = DATA_READ_CHUNK;
+ if (l > allsize)
+ l = allsize;
+ if (l && fread(buf + left, l, 1, data.fp) != 1)
+ {
+ pool_debug(mypool, SAT_ERROR, "unexpected EOF\n");
+ data.error = SOLV_ERROR_EOF;
+ break;
+ }
+ allsize -= l;
+ left += l;
+ bufend = buf + left;
+ if (allsize + left < maxsize)
+ maxsize = allsize + left;
+ dp = buf;
+ }
+ needchunk = 0;
+ }
+
key = *keyp++;
#if 0
printf("key %d at %d\n", key, keyp - 1 - schemadata);
@@ -1058,42 +1096,6 @@ printf("pop flexarray %d %d\n", keydepth, nentries);
if (keydepth == 0)
data.mainschemaoffsets[keyp - 1 - (schemadata + schemata[data.mainschema])] = data.incoredatalen;
- if (keydepth == 0 || needchunk)
- {
- int left = bufend - dp;
- /* read data chunk to dp */
- if (data.error)
- break;
- if (left < 0)
- {
- pool_debug(mypool, SAT_ERROR, "buffer overrun\n");
- data.error = SOLV_ERROR_EOF;
- break;
- }
- if (left < maxsize)
- {
- if (left)
- memmove(buf, dp, left);
- l = maxsize - left;
- if (l < DATA_READ_CHUNK)
- l = DATA_READ_CHUNK;
- if (l > allsize)
- l = allsize;
- if (l && fread(buf + left, l, 1, data.fp) != 1)
- {
- pool_debug(mypool, SAT_ERROR, "unexpected EOF\n");
- data.error = SOLV_ERROR_EOF;
- break;
- }
- allsize -= l;
- left += l;
- bufend = buf + left;
- if (allsize + left < maxsize)
- maxsize = allsize + left;
- dp = buf;
- }
- needchunk = 0;
- }
#if 0
printf("=> %s %s %p\n", id2str(pool, keys[key].name), id2str(pool, keys[key].type), s);
--
To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org
For additional commands, e-mail: zypp-commit+help@opensuse.org