From 85d28994b93ee020dae26193e81aacf4be90b3ea Mon Sep 17 00:00:00 2001 From: jbj Date: Sun, 31 Oct 2004 20:22:01 +0000 Subject: - python: remove ".A" from creaky ts.check() tuple return (#135008). - python: fix RPMPROB_BADRELOCATE segfault return in ts.check (#137116). - revert selinux patch until fc3 release. - reprise file conflicts yet again, flip/flop/flip/flop ... - fix: buffer overrun displaying ko_KR (#135389). CVS patchset: 7532 CVS date: 2004/10/31 20:22:01 --- lib/formats.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/formats.c b/lib/formats.c index c5e42f048..ebfc1db24 100644 --- a/lib/formats.c +++ b/lib/formats.c @@ -432,11 +432,15 @@ static /*@only@*/ char * pgpsigFormat(int_32 type, const void * data, } else { pgpDig dig = pgpNewDig(); pgpDigParams sigp = &dig->signature; - size_t nb = 80; + size_t nb = 0; + const char *tempstr; (void) pgpPrtPkts(pkt, pktlen, dig, 0); - val = t = xmalloc(nb + 1); + val = NULL; + again: + nb += 100; + val = t = xrealloc(val, nb + 1); /*@-boundswrite@*/ switch (sigp->pubkey_algo) { @@ -447,10 +451,12 @@ static /*@only@*/ char * pgpsigFormat(int_32 type, const void * data, t = stpcpy(t, "RSA"); break; default: - sprintf(t, "%d", sigp->pubkey_algo); + snprintf(t, nb - (t - val), "%d", sigp->pubkey_algo); t += strlen(t); break; } + if (t + 5 >= val + nb) + goto again; *t++ = '/'; switch (sigp->hash_algo) { case PGPHASHALGO_MD5: @@ -460,10 +466,12 @@ static /*@only@*/ char * pgpsigFormat(int_32 type, const void * data, t = stpcpy(t, "SHA1"); break; default: - sprintf(t, "%d", sigp->hash_algo); + snprintf(t, nb - (t - val), "%d", sigp->hash_algo); t += strlen(t); break; } + if (t + strlen (", ") + 1 >= val + nb) + goto again; t = stpcpy(t, ", "); @@ -474,8 +482,13 @@ static /*@only@*/ char * pgpsigFormat(int_32 type, const void * data, (void) strftime(t, (nb - (t - val)), "%c", tstruct); } t += strlen(t); + if (t + strlen (", Key ID ") + 1 >= val + nb) + goto again; t = stpcpy(t, ", Key ID "); - t = stpcpy(t, pgpHexStr(sigp->signid, sizeof(sigp->signid))); + tempstr = pgpHexStr(sigp->signid, sizeof(sigp->signid)); + if (t + strlen (tempstr) > val + nb) + goto again; + t = stpcpy(t, tempstr); /*@=boundswrite@*/ dig = pgpFreeDig(dig); -- cgit v1.2.3