Commit 748e2c54 authored by Niels Möller's avatar Niels Möller

Helper read_file: Use size_t for sizes, and uint8_t for the contents.

parent 544b4047
2016-08-05 Niels Möller <nisse@lysator.liu.se>
* examples/io.c (read_file): Use size_t for sizes, and uint8_t for
the contents.
2016-08-04 Niels Möller <nisse@lysator.liu.se>
* dsa-sign.c (dsa_sign): Return failure if p is even, so that an
......
......@@ -74,11 +74,11 @@ werror(const char *format, ...)
}
}
unsigned
read_file(const char *name, unsigned max_size, char **contents)
size_t
read_file(const char *name, size_t max_size, uint8_t **contents)
{
unsigned size, done;
char *buffer;
size_t size, done;
uint8_t *buffer;
FILE *f;
f = fopen(name, "rb");
......@@ -92,7 +92,7 @@ read_file(const char *name, unsigned max_size, char **contents)
for (buffer = NULL, done = 0;; size *= 2)
{
char *p;
uint8_t *p;
if (max_size && size > max_size)
size = max_size;
......@@ -167,7 +167,7 @@ int
simple_random(struct yarrow256_ctx *ctx, const char *name)
{
unsigned length;
char *buffer;
uint8_t *buffer;
if (name)
length = read_file(name, 0, &buffer);
......
......@@ -52,8 +52,8 @@ werror(const char *format, ...) PRINTF_STYLE(1, 2);
* treated as an error; return value is zero, and no space is
* allocated. The returned data is NUL-terminated, for convenience. */
unsigned
read_file(const char *name, unsigned size, char **buffer);
size_t
read_file(const char *name, size_t size, uint8_t **buffer);
int
write_file(const char *name, unsigned size, const char *buffer);
......
......@@ -47,7 +47,7 @@ read_rsa_key(const char *name,
struct rsa_private_key *priv)
{
unsigned length;
char *buffer;
uint8_t *buffer;
int res;
length = read_file(name, 0, &buffer);
......
......@@ -44,7 +44,7 @@
static int
read_signature(const char *name, mpz_t s)
{
char *buffer;
uint8_t *buffer;
unsigned length;
int res;
......@@ -52,7 +52,7 @@ read_signature(const char *name, mpz_t s)
if (!length)
return 0;
res = (mpz_set_str(s, buffer, 16) == 0);
res = (mpz_set_str(s, (const char *) buffer, 16) == 0);
free(buffer);
return res;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment