From: Matthijs Mekking Date: Mon, 2 Dec 2013 11:46:49 +0000 (+0100) Subject: fix ldns_sha1 overwrites input buffer. X-Git-Tag: release-1.6.17rc1~9^2~2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b4a09ac6bb04784e78a7e21fed6db3ff01be4913;p=thirdparty%2Fldns.git fix ldns_sha1 overwrites input buffer. --- diff --git a/sha1.c b/sha1.c index 5dec680a..bb2b97b4 100644 --- a/sha1.c +++ b/sha1.c @@ -122,19 +122,21 @@ ldns_sha1_update(ldns_sha1_ctx *context, const unsigned char *data, unsigned int { unsigned int i; unsigned int j; + unsigned char d[len]; + (void)memcpy((void*)d, data, len); j = (unsigned)(uint32_t)((context->count >> 3) & 63); context->count += (len << 3); if ((j + len) > 63) { - memmove(&context->buffer[j], data, (i = 64 - j)); + memmove(&context->buffer[j], d, (i = 64 - j)); ldns_sha1_transform(context->state, context->buffer); for ( ; i + 63 < len; i += 64) { - ldns_sha1_transform(context->state, &data[i]); + ldns_sha1_transform(context->state, &d[i]); } j = 0; } else i = 0; - memmove(&context->buffer[j], &data[i], len - i); + memmove(&context->buffer[j], &d[i], len - i); }