diff options
author | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-03-03 09:26:01 +0000 |
---|---|---|
committer | Rafael Garcia-Suarez <rgarciasuarez@mandriva.org> | 2006-03-03 09:26:01 +0000 |
commit | 6c0d55f82d77e5e80ec5591f98622e5c9b7217b1 (patch) | |
tree | 0fc56ae2acb33eba95bcddb70066187b59f85a23 | |
parent | 03db6e24776d9d1b8125401492958031fcd59f33 (diff) | |
download | perl-URPM-6c0d55f82d77e5e80ec5591f98622e5c9b7217b1.tar perl-URPM-6c0d55f82d77e5e80ec5591f98622e5c9b7217b1.tar.gz perl-URPM-6c0d55f82d77e5e80ec5591f98622e5c9b7217b1.tar.bz2 perl-URPM-6c0d55f82d77e5e80ec5591f98622e5c9b7217b1.tar.xz perl-URPM-6c0d55f82d77e5e80ec5591f98622e5c9b7217b1.zip |
Use a smaller buffer for the return value of verify_rpm, and guard against overflows
-rw-r--r-- | URPM.xs | 46 |
1 files changed, 21 insertions, 25 deletions
@@ -3349,7 +3349,7 @@ Urpm_verify_rpm(filename, ...) FD_t fd; int i; char * fmtsig = NULL; - char buffer[8192]; + char buffer[512]; rpmts ts = NULL; CODE: for (i = 1; i < items-1; i+=2) { @@ -3411,32 +3411,28 @@ Urpm_verify_rpm(filename, ...) rpmTagTable, rpmHeaderFormats, NULL); headerFree(ret); switch(rc) { - case RPMRC_OK: - sprintf(buffer, "%s", fmtsig); - RETVAL = buffer; - break; - case RPMRC_NOTFOUND: - sprintf(buffer, "%s (missing key) NOT OK", fmtsig); - RETVAL = buffer; - break; - case RPMRC_FAIL: - RETVAL = "(can't get key) NOT OK"; - break; - case RPMRC_NOTTRUSTED: - sprintf(buffer, "%s (Key not trusted) OK", fmtsig); - RETVAL = buffer; - break; - case RPMRC_NOKEY: - sprintf(buffer, "(no key found) OK"); - RETVAL = buffer; - break; - default: /* can't happen */ - sprintf(buffer, "Unknown return value %d (NOT OK)", rc); - RETVAL = buffer; - break; + case RPMRC_OK: + snprintf(buffer, sizeof(buffer), "%s", fmtsig); + break; + case RPMRC_NOTFOUND: + snprintf(buffer, sizeof(buffer), "%s (missing key) NOT OK", fmtsig); + break; + case RPMRC_FAIL: + snprintf(buffer, sizeof(buffer), "(can't get key) NOT OK"); + break; + case RPMRC_NOTTRUSTED: + snprintf(buffer, sizeof(buffer), "%s (Key not trusted) OK", fmtsig); + break; + case RPMRC_NOKEY: + snprintf(buffer, sizeof(buffer), "(no key found) OK"); + break; + default: /* can't happen */ + snprintf(buffer, sizeof(buffer), "Unknown return value %d (NOT OK)", rc); + break; } + RETVAL = buffer; } else { - RETVAL = "Unable to read rpm file"; + RETVAL = "Unable to read rpm file"; } } |