xbps-rindex: --sign bugfix to avoid garbage in the PEM RSA public key buffer.

This commit is contained in:
Juan RP 2014-03-31 12:00:08 +02:00
parent 4530c79bb2
commit ee9479cc57
2 changed files with 8 additions and 3 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
xbps-0.35 (???):
* xbps-rindex(8): fixed a bug while signing repositories in that sometimes
the PEM RSA public key buffer contained unwanted garbage.
* Make sure that required root symlinks in void are never removed or detected
as obsoletes; added new test cases to stress the code works as expected.

View File

@ -71,7 +71,8 @@ static char *
pubkey_from_privkey(RSA *rsa)
{
BIO *bp;
char *buf;
char *buf = NULL;
int len;
bp = BIO_new(BIO_s_mem());
assert(bp);
@ -85,9 +86,10 @@ pubkey_from_privkey(RSA *rsa)
/* XXX (xtraeme) 8192 should be always enough? */
buf = malloc(8192);
assert(buf);
BIO_read(bp, buf, 8192);
len = BIO_read(bp, buf, 8191);
BIO_free(bp);
ERR_free_strings();
buf[len] = '\0';
return buf;
}
@ -128,7 +130,7 @@ sign_repo(struct xbps_handle *xhp, const char *repodir,
unsigned int siglen;
uint16_t rpubkeysize, pubkeysize;
const char *arch, *pkgver, *rsignedby = NULL;
char *binpkg, *binpkg_sig, *buf, *defprivkey;
char *binpkg = NULL, *binpkg_sig = NULL, *buf = NULL, *defprivkey = NULL;
int binpkg_fd, binpkg_sig_fd, rv = 0;
bool flush = false;