[zypp-commit] r7463 - /trunk/sat-solver/src/source.c
Author: mlschroe Date: Mon Oct 8 11:17:33 2007 New Revision: 7463 URL: http://svn.opensuse.org/viewcvs/zypp?rev=7463&view=rev Log: fix segfault Modified: trunk/sat-solver/src/source.c Modified: trunk/sat-solver/src/source.c URL: http://svn.opensuse.org/viewcvs/zypp/trunk/sat-solver/src/source.c?rev=7463&r1=7462&r2=7463&view=diff ============================================================================== --- trunk/sat-solver/src/source.c (original) +++ trunk/sat-solver/src/source.c Mon Oct 8 11:17:33 2007 @@ -284,9 +284,8 @@ source_fix_legacy(Source *source, unsigned int provides, unsigned int supplements) { Pool *pool = source->pool; - const char *p, *dep; Id id, idp, idl, idns; - char buf[1024]; + char buf[1024], oc, *p, *dep; int i; if (provides) @@ -296,17 +295,17 @@ id = source->idarraydata[i]; if (ISRELDEP(id)) continue; - dep = id2str(pool, id); + dep = (char *)id2str(pool, id); if (!strncmp(dep, "locale(", 7) && strlen(dep) < sizeof(buf)) { - dep += 7; idp = 0; + strcpy(buf, dep); + dep = buf + 7; if ((p = strchr(dep, ':')) != 0 && p != dep) { - strncpy(buf, dep, p - dep); - buf[p - dep] = 0; - idp = str2id(pool, buf, 1); - dep = p + 1; + *p++ = 0; + idp = str2id(pool, dep, 1); + dep = p; } id = 0; while ((p = strchr(dep, ';')) != 0) @@ -316,22 +315,22 @@ dep = p + 1; continue; } - strcpy(buf, "Locale("); - strncpy(buf + 7, dep, p - dep); - buf[p - dep + 7] = ')'; - buf[p - dep + 8] = 0; - idl = str2id(pool, buf, 1); + strncpy(dep - 7, "Locale(", 7); + *p++ = ')'; + oc = *p; + *p = 0; + idl = str2id(pool, dep - 7, 1); + *p = oc; if (id) id = rel2id(pool, id, idl, REL_OR, 1); else id = idl; - dep = p + 1; + dep = p; } if (dep[0] && dep[1]) { - strcpy(buf, "Locale("); - strcpy(buf + 7, dep); - idl = str2id(pool, buf, 1); + strncpy(dep - 7, "Locale(", 7); + idl = str2id(pool, dep - 7, 1); if (id) id = rel2id(pool, id, idl, REL_OR, 1); else @@ -344,11 +343,12 @@ } else if ((p = strchr(dep, ':')) != 0 && p != dep && p[1] == '/' && strlen(dep) < sizeof(buf)) { - strncpy(buf, dep, p - dep); - buf[p - dep] = 0; + strcpy(buf, dep); + p = buf + (p - dep); + *p++ = 0; idp = str2id(pool, buf, 1); idns = str2id(pool, "namespace:installed", 1); - id = str2id(pool, p + 1, 1); + id = str2id(pool, p, 1); id = rel2id(pool, idns, id, REL_NAMESPACE, 1); id = rel2id(pool, idp, id, REL_AND, 1); supplements = source_addid_dep(source, supplements, id, 0); @@ -362,29 +362,26 @@ id = source->idarraydata[i]; if (ISRELDEP(id)) continue; - dep = id2str(pool, id); + dep = (char *)id2str(pool, id); if (!strncmp(dep, "modalias(", 9) && dep[9] && dep[10] && strlen(dep) < sizeof(buf)) { - p = strchr(dep + 9, ':'); + strcpy(buf, dep); + p = strchr(buf + 9, ':'); idns = str2id(pool, "namespace:modalias", 1); - if (p && p != dep + 9 && strchr(p + 1, ':')) + if (p && p != buf + 9 && strchr(p + 1, ':')) { - dep += 9; - strncpy(buf, dep, p - dep); - buf[p - dep] = 0; - idp = str2id(pool, buf, 1); - strcpy(buf, p + 1); - buf[strlen(buf) - 1] = 0; - id = str2id(pool, buf, 1); + *p++ = 0; + idp = str2id(pool, buf + 9, 1); + p[strlen(p) - 1] = 0; + id = str2id(pool, p, 1); id = rel2id(pool, idns, id, REL_NAMESPACE, 1); id = rel2id(pool, idp, id, REL_AND, 1); } else { - dep += 9; - strcpy(buf, dep); - buf[strlen(buf) - 1] = 0; - id = str2id(pool, buf, 1); + p = buf + 9; + p[strlen(p) - 1] = 0; + id = str2id(pool, p, 1); id = rel2id(pool, idns, id, REL_NAMESPACE, 1); } if (id) @@ -392,8 +389,9 @@ } else if (!strncmp(dep, "packageand(", 11) && strlen(dep) < sizeof(buf)) { + strcpy(buf, dep); id = 0; - dep += 11; + dep = buf + 11; while ((p = strchr(dep, ':')) != 0) { if (p == dep) @@ -401,20 +399,18 @@ dep = p + 1; continue; } - strncpy(buf, dep, p - dep); - buf[p - dep] = 0; - idp = str2id(pool, buf, 1); + *p++ = 0; + idp = str2id(pool, dep, 1); if (id) id = rel2id(pool, id, idp, REL_AND, 1); else id = idp; - dep = p + 1; + dep = p; } if (dep[0] && dep[1]) { - strcpy(buf, dep); - buf[strlen(buf) - 1] = 0; - idp = str2id(pool, buf, 1); + dep[strlen(dep) - 1] = 0; + idp = str2id(pool, dep, 1); if (id) id = rel2id(pool, id, idp, REL_AND, 1); else -- To unsubscribe, e-mail: zypp-commit+unsubscribe@opensuse.org For additional commands, e-mail: zypp-commit+help@opensuse.org
participants (1)
-
mlschroe@svn.opensuse.org