summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJindrich Novy <jnovy@dhcp-lab-186.brq.redhat.com>2008-04-15 17:35:13 +0200
committerJindrich Novy <jnovy@dhcp-lab-186.brq.redhat.com>2008-04-15 17:35:13 +0200
commitecaa34a9dc564848f4f1bf3cd413b27da2b9c9ff (patch)
tree95bd10eee7d52091995163f8a5b2c6160ae5cbc9 /lib
parent0097e6fe952a6f39b99e4761ab613f99d34c142c (diff)
downloadrpm-ecaa34a9dc564848f4f1bf3cd413b27da2b9c9ff.tar.gz
rpm-ecaa34a9dc564848f4f1bf3cd413b27da2b9c9ff.tar.bz2
rpm-ecaa34a9dc564848f4f1bf3cd413b27da2b9c9ff.zip
Get rid of string hackery and overflows while rpm -V
Diffstat (limited to 'lib')
-rw-r--r--lib/verify.c27
1 files changed, 10 insertions, 17 deletions
diff --git a/lib/verify.c b/lib/verify.c
index 00f0d693e..f10d1a647 100644
--- a/lib/verify.c
+++ b/lib/verify.c
@@ -247,13 +247,9 @@ static int verifyHeader(QVA_t qva, const rpmts ts, rpmfi fi)
/* FIX: union? */
rpmVerifyAttrs omitMask = ((qva->qva_flags & VERIFY_ATTRS) ^ VERIFY_ATTRS);
int ec = 0; /* assume no problems */
- char * t, * te;
- char buf[BUFSIZ];
+ char *buf = NULL;
int i;
- te = t = buf;
- *te = '\0';
-
fi = rpmfiLink(fi, RPMDBG_M("verifyHeader"));
fi = rpmfiInit(fi, 0);
if (fi != NULL) /* XXX lclint */
@@ -271,7 +267,7 @@ static int verifyHeader(QVA_t qva, const rpmts ts, rpmfi fi)
rc = rpmVerifyFile(ts, fi, &verifyResult, omitMask);
if (rc) {
if (!(fileAttrs & (RPMFILE_MISSINGOK|RPMFILE_GHOST)) || rpmIsVerbose()) {
- sprintf(te, _("missing %c %s"),
+ rasprintf(&buf, _("missing %c %s"),
((fileAttrs & RPMFILE_CONFIG) ? 'c' :
(fileAttrs & RPMFILE_DOC) ? 'd' :
(fileAttrs & RPMFILE_GHOST) ? 'g' :
@@ -279,11 +275,12 @@ static int verifyHeader(QVA_t qva, const rpmts ts, rpmfi fi)
(fileAttrs & RPMFILE_PUBKEY) ? 'P' :
(fileAttrs & RPMFILE_README) ? 'r' : ' '),
rpmfiFN(fi));
- te += strlen(te);
if ((verifyResult & RPMVERIFY_LSTATFAIL) != 0 &&
errno != ENOENT) {
- sprintf(te, " (%s)", strerror(errno));
- te += strlen(te);
+ char *app;
+ rasprintf(&app, " (%s)", strerror(errno));
+ rstrcat(&buf, app);
+ free(app);
}
ec = rc;
}
@@ -317,7 +314,7 @@ static int verifyHeader(QVA_t qva, const rpmts ts, rpmfi fi)
#undef _verifylink
#undef _verify
- sprintf(te, "%s%s%s%s%s%s%s%s %c %s",
+ rasprintf(&buf, "%s%s%s%s%s%s%s%s %c %s",
size, mode, MD5, rdev, link, user, group, mtime,
((fileAttrs & RPMFILE_CONFIG) ? 'c' :
(fileAttrs & RPMFILE_DOC) ? 'd' :
@@ -326,15 +323,11 @@ static int verifyHeader(QVA_t qva, const rpmts ts, rpmfi fi)
(fileAttrs & RPMFILE_PUBKEY) ? 'P' :
(fileAttrs & RPMFILE_README) ? 'r' : ' '),
rpmfiFN(fi));
- te += strlen(te);
}
- if (te > t) {
- *te++ = '\n';
- *te = '\0';
- rpmlog(RPMLOG_NOTICE, "%s", t);
- te = t = buf;
- *t = '\0';
+ if (buf) {
+ rpmlog(RPMLOG_NOTICE, "%s\n", buf);
+ buf = _free(buf);
}
}
fi = rpmfiUnlink(fi, RPMDBG_M("verifyHeader"));