commit fc6a77941c7ea088c77843ceb66daa8a4f0e93b0
parent 113c9b2f5164181143ddfae0b9f36eef9aeaaad5
Author: William Casarin <jb55@jb55.com>
Date: Mon, 3 Jun 2019 13:57:53 -0700
fixes
Diffstat:
4 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/script.c b/script.c
@@ -8,6 +8,7 @@
#include "sha256.h"
#include "ripemd160.h"
#include <stdio.h>
+#include <inttypes.h>
/* #define SCRIPTERR(serr) script_add_error(c, opcode, serr) */
#define SCRIPTERR(serr) { err = serr; goto evalerror; }
@@ -114,7 +115,7 @@ int
script_eval(const u8 *script, size_t script_size, struct stack *stack,
struct result *result) {
int op_count = 0;
- u32 tmplen;
+ u32 tmplen = 0;
char *err = NULL;
const u8 *p = script;
const u8 *top = script + script_size;
@@ -140,7 +141,7 @@ script_eval(const u8 *script, size_t script_size, struct stack *stack,
while (p < top) {
c++;
- script_getop(&p, top, &opcode, (u8*)tmpbuf, ARRAY_SIZE(tmpbuf), &tmplen);
+ script_getop(&p, top, &opcode, tmpbytes, sizeof(tmpbytes), &tmplen);
int if_exec = !stack_any_val(ifstack, falseval);
// Note OP_RESERVED does not count towards the opcode limit.
@@ -806,7 +807,7 @@ void script_serialize(struct stack *stack, u8 *buf, int buflen, int* len)
struct val *valp;
void **sp;
u8 *p = buf;
- u32 valsize;
+ u32 valsize = 0;
*len = 0;
sp = stack->bottom;
diff --git a/script_num.c b/script_num.c
@@ -102,11 +102,10 @@ enum sn_result
sn_from_data(u8 *data, u16 size, struct num **num) {
u16 ind;
s64 i;
- i = int_from_data(data, size);
- if (int_overflowed(i)) {
- *num = 0;
+ if (size > 4)
return SN_ERR_OVERFLOWED_INT;
- }
+ i = int_from_data(data, size);
+ /* printf("%" PRId64" okkkk\n", i); */
*num = num_pool_new(&ind);
(*num)->val = i;
(*num)->ind = ind;
@@ -136,6 +135,7 @@ sn_from_val(struct val val, struct num ** sn, int require_minimal) {
(*sn)->val = val.ind;
return SN_SUCCESS;
+ case VT_RAW:
case VT_DATA: {
u8 *data;
u32 size;
diff --git a/val.c b/val.c
@@ -93,6 +93,7 @@ void val_serialize(struct val val, u32 *len, u8 *buf, int bufsize) {
return;
}
case VT_SMALLINT:
+ assert(0);
*len = 1;
n = val.ind;
if (n >= -1 && n <= 16) {
diff --git a/valstack.h b/valstack.h
@@ -38,8 +38,8 @@ stack_push_val(struct stack *stack, struct val val) {
}
static inline void
-stack_push_data(struct stack *stack, u8 *data, int len) {
- struct val val = { .type = VT_DATA };
+stack_push_raw(struct stack *stack, u8 *data, int len) {
+ struct val val = { .type = VT_RAW };
u8 *p;
u16 ind;
p = byte_pool_new(len, &ind);