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:
4
base58.c
4
base58.c
@@ -15,6 +15,7 @@
|
|||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
#include <sys/types.h>
|
||||||
|
|
||||||
#include "libbase58.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;
|
const uint8_t *bin = data;
|
||||||
int carry;
|
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])
|
while (zcount < binsz && !bin[zcount])
|
||||||
++zcount;
|
++zcount;
|
||||||
|
|||||||
Reference in New Issue
Block a user