From 4c8a179e875e15164a3412cad5fb05822e4bde20 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Mon, 27 Oct 2014 14:18:31 +0100 Subject: [PATCH] issue #76 Setting payload < 512 should not error Thanks gmadkat --- src/context.c | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/src/context.c b/src/context.c index 9e8553bf..689a4373 100755 --- a/src/context.c +++ b/src/context.c @@ -1276,19 +1276,20 @@ getdns_return_t getdns_context_set_edns_maximum_udp_payload_size(struct getdns_context *context, uint16_t value) { - RETURN_IF_NULL(context, GETDNS_RETURN_INVALID_PARAMETER); - /* check for < 512. uint16_t won't let it go above max) */ - if (value < 512) { - return GETDNS_RETURN_CONTEXT_UPDATE_FAIL; - } - set_ub_edns_maximum_udp_payload_size(context, value); - if (value != context->edns_maximum_udp_payload_size) { - context->edns_maximum_udp_payload_size = value; - dispatch_updated(context, - GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE); - } + if (!context) + return GETDNS_RETURN_INVALID_PARAMETER; - return GETDNS_RETURN_GOOD; + /* check for < 512. uint16_t won't let it go above max) */ + if (value < 512) + value = 512; + + set_ub_edns_maximum_udp_payload_size(context, value); + if (value != context->edns_maximum_udp_payload_size) { + context->edns_maximum_udp_payload_size = value; + dispatch_updated(context, + GETDNS_CONTEXT_CODE_EDNS_MAXIMUM_UDP_PAYLOAD_SIZE); + } + return GETDNS_RETURN_GOOD; } /* getdns_context_set_edns_maximum_udp_payload_size */ /*