X-Git-Url: http://erislabs.net/gitweb/?a=blobdiff_plain;f=lib%2Fmd2.c;h=e585eb808cdfe387e1814723c56eb66e1d7fb47c;hb=c910e6ce03eefaf1b92911b3de50b2605d810d34;hp=cb4c63b2b7d8a86dafff3c6b5514ff4e13cff925;hpb=82381b9e5b37125305709d412d8322b35e5c4796;p=gnulib.git diff --git a/lib/md2.c b/lib/md2.c index cb4c63b2b..e585eb808 100644 --- a/lib/md2.c +++ b/lib/md2.c @@ -24,6 +24,7 @@ #include "md2.h" +#include #include #include @@ -33,7 +34,7 @@ # include "unlocked-io.h" #endif -#define BLOCKSIZE 4096 +#define BLOCKSIZE 32768 #if BLOCKSIZE % 64 != 0 # error "invalid BLOCKSIZE" #endif @@ -94,9 +95,12 @@ int md2_stream (FILE *stream, void *resblock) { struct md2_ctx ctx; - char buffer[BLOCKSIZE + 72]; size_t sum; + char *buffer = malloc (BLOCKSIZE + 72); + if (!buffer) + return 1; + /* Initialize the computation context. */ md2_init_ctx (&ctx); @@ -125,7 +129,10 @@ md2_stream (FILE *stream, void *resblock) exit the loop after a partial read due to e.g., EAGAIN or EWOULDBLOCK. */ if (ferror (stream)) - return 1; + { + free (buffer); + return 1; + } goto process_partial_block; } @@ -150,6 +157,7 @@ process_partial_block:; /* Construct result in desired memory. */ md2_finish_ctx (&ctx, resblock); + free (buffer); return 0; }