Fix bug in razor_create_dir() path component loop.
authorKristian Høgsberg <krh@redhat.com>
Thu, 6 Mar 2008 05:27:43 +0000 (00:27 -0500)
committerKristian Høgsberg <krh@redhat.com>
Thu, 6 Mar 2008 05:55:51 +0000 (00:55 -0500)
rpm.c
util.c

diff --git a/rpm.c b/rpm.c
index 0e8a7c3..255aa35 100644 (file)
--- a/rpm.c
+++ b/rpm.c
@@ -526,7 +526,6 @@ razor_importer_add_rpm(struct razor_importer *importer, struct razor_rpm *rpm)
 {
        const char *name, *version, *release;
        const uint_32 *epoch;
-       struct rpm_header_index *epoch_header;
        char evr[128], buf[16];
 
        name = razor_rpm_get_indirect(rpm, RPMTAG_NAME, NULL);
@@ -534,7 +533,7 @@ razor_importer_add_rpm(struct razor_importer *importer, struct razor_rpm *rpm)
        version = razor_rpm_get_indirect(rpm, RPMTAG_VERSION, NULL);
        release = razor_rpm_get_indirect(rpm, RPMTAG_RELEASE, NULL);
 
-       if (epoch_header) {
+       if (epoch) {
                snprintf(buf, sizeof buf, "%u", ntohl(*epoch));
                razor_build_evr(evr, sizeof evr, buf, version, release);
        } else {
diff --git a/util.c b/util.c
index 2501f65..a48b77d 100644 (file)
--- a/util.c
+++ b/util.c
@@ -21,8 +21,11 @@ razor_create_dir(const char *root, const char *path)
        strcpy(buffer, root);
        p = buffer + strlen(buffer);
        slash = path;
-       for (slash = path; slash[1] != '\0'; slash = next) {
+       for (slash = path; *slash != '\0'; slash = next) {
                next = strchr(slash + 1, '/');
+               if (next == NULL)
+                       next = slash + strlen(slash);
+
                memcpy(p, slash, next - slash);
                p += next - slash;
                *p = '\0';