Skip to content
This repository was archived by the owner on Apr 17, 2020. It is now read-only.

Commit 6b2d844

Browse files
committed
bitcoin: use ccan/mem instead of rolling own check_mem function.
Reported-by: John Newbery Signed-off-by: Rusty Russell <[email protected]>
1 parent be58e45 commit 6b2d844

File tree

4 files changed

+7
-25
lines changed

4 files changed

+7
-25
lines changed

Makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ PROGRAMS := $(TEST_CLI_PROGRAMS) $(TEST_PROGRAMS)
8888
HEADERS := $(filter-out gen_*, $(wildcard *.h)) $(wildcard bitcoin/*.h) gen_state_names.h
8989

9090
CCANDIR := ccan/
91-
CFLAGS := -g -Wall -I $(CCANDIR) -I secp256k1/include/ -DVALGRIND_HEADERS=1 $(FEATURES)
91+
CFLAGS := -g -Wall -I $(CCANDIR) -I secp256k1/include/ $(FEATURES)
9292
LDLIBS := -lcrypto -lprotobuf-c
9393
$(PROGRAMS): CFLAGS+=-I.
9494

bitcoin/shadouble.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#include "shadouble.h"
2-
#include "valgrind.h"
2+
#include <ccan/mem/mem.h>
33

44
void sha256_double(struct sha256_double *shadouble, const void *p, size_t len)
55
{
6-
sha256(&shadouble->sha, check_mem(p, len), len);
6+
sha256(&shadouble->sha, memcheck(p, len), len);
77
sha256(&shadouble->sha, &shadouble->sha, sizeof(shadouble->sha));
88
}
99

bitcoin/tx.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#include <ccan/crypto/sha256/sha256.h>
22
#include <ccan/endian/endian.h>
33
#include <ccan/err/err.h>
4+
#include <ccan/mem/mem.h>
45
#include <ccan/read_write_all/read_write_all.h>
56
#include <ccan/str/hex/hex.h>
67
#include <ccan/tal/grab_file/grab_file.h>
78
#include <assert.h>
89
#include "tx.h"
9-
#include "valgrind.h"
1010

1111
enum styles {
1212
/* Add the CT padding stuff to amount. */
@@ -197,7 +197,7 @@ static void add_tx(const struct bitcoin_tx *tx,
197197
static void add_sha(const void *data, size_t len, void *shactx_)
198198
{
199199
struct sha256_ctx *ctx = shactx_;
200-
sha256_update(ctx, check_mem(data, len), len);
200+
sha256_update(ctx, memcheck(data, len), len);
201201
}
202202

203203
void sha256_tx_for_sig(struct sha256_ctx *ctx, const struct bitcoin_tx *tx,
@@ -219,7 +219,7 @@ static void add_linearize(const void *data, size_t len, void *pptr_)
219219
size_t oldsize = tal_count(*pptr);
220220

221221
tal_resize(pptr, oldsize + len);
222-
memcpy(*pptr + oldsize, check_mem(data, len), len);
222+
memcpy(*pptr + oldsize, memcheck(data, len), len);
223223
}
224224

225225
u8 *linearize_tx(const tal_t *ctx, const struct bitcoin_tx *tx)
@@ -278,7 +278,7 @@ static const u8 *pull(const u8 **cursor, size_t *max, void *copy, size_t n)
278278
*max -= n;
279279
if (copy)
280280
memcpy(copy, p, n);
281-
return check_mem(p, n);
281+
return memcheck(p, n);
282282
}
283283

284284
static u64 pull_varint(const u8 **cursor, size_t *max)

bitcoin/valgrind.h

-18
This file was deleted.

0 commit comments

Comments
 (0)