Revert variable signedness changes.

In the line:

    for (carry = bin[i], j = size - 1; (j > high) || carry; --j)

my analysis missed that the compare (j > high) is always true when
high is 0 and j wraps around. So although the loop does not store
through a negative 'j' offset, it does require j to become negative
in order to terminate the loop in that case. My apologies.
This commit is contained in:
Jon Griffiths
2016-04-10 02:21:41 +12:00
parent 5df7d3b19a
commit a861d3c57f

View File

@@ -15,6 +15,7 @@
#include <stddef.h>
#include <stdint.h>
#include <string.h>
#include <sys/types.h>
#include "libbase58.h"
@@ -145,7 +146,8 @@ bool b58enc(char *b58, size_t *b58sz, const void *data, size_t binsz)
{
const uint8_t *bin = data;
int carry;
size_t i, j, size, high, zcount = 0;
ssize_t i, j, high, zcount = 0;
size_t size;
while (zcount < binsz && !bin[zcount])
++zcount;