index : pacman | |
Archlinux32 fork of pacman | gitolite user |
summaryrefslogtreecommitdiff |
author | Dan McGee <dan@archlinux.org> | 2011-08-14 20:47:08 -0500 |
---|---|---|
committer | Dan McGee <dan@archlinux.org> | 2011-08-15 12:11:59 -0500 |
commit | fa4aad5b509946f947d9b2553d09f5f35be24915 (patch) | |
tree | d588e93fb9d3d41c6e582f625eaed82c19ff3109 /lib/libalpm/signing.c | |
parent | f3f39cef84330b734c36a60e48cf26a3f3e1f76c (diff) |
-rw-r--r-- | lib/libalpm/signing.c | 20 |
diff --git a/lib/libalpm/signing.c b/lib/libalpm/signing.c index 6ca32fd5..7521e3ad 100644 --- a/lib/libalpm/signing.c +++ b/lib/libalpm/signing.c @@ -169,22 +169,12 @@ error: */ static int decode_signature(const char *base64_data, unsigned char **data, size_t *data_len) { - unsigned char *usline; - size_t len; - - len = strlen(base64_data); - usline = (unsigned char *)base64_data; - int ret; - size_t destlen = 0; - /* get the necessary size for the buffer by passing 0 */ - ret = base64_decode(NULL, &destlen, usline, len); - if(ret != 0 && ret != POLARSSL_ERR_BASE64_BUFFER_TOO_SMALL) { - goto error; - } - /* alloc our memory and repeat the call to decode */ + size_t len = strlen(base64_data); + unsigned char *usline = (unsigned char *)base64_data; + /* reasonable allocation of expected length is 3/4 of encoded length */ + size_t destlen = len * 3 / 4; MALLOC(*data, destlen, goto error); - ret = base64_decode(*data, &destlen, usline, len); - if(ret != 0) { + if(base64_decode(*data, &destlen, usline, len)) { goto error; } *data_len = destlen; |