Skip to content

Commit 8654bc9

Browse files
niallorjay
authored andcommitted
doh: fix doh_encode's error return value
- Return 0 on doh_encode error. This makes the values returned on error by doh_encode() consistent with the post-invocation test. Prior to this change doh_encode, which returns a size_t of bytes written on success, erroneously returned DOHcodes on error (eg DOH_TOO_SMALL_BUFFER (4), ie 4 bytes written, which was wrong). Fixes #40 Closes #41
1 parent 17fd81d commit 8654bc9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

doh.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ static size_t doh_encode(const char *host,
256256
const char *hostp = host;
257257

258258
if(len < (12 + hostlen + 6))
259-
return DOH_TOO_SMALL_BUFFER;
259+
return 0;
260260

261261
*dnsp++ = 0; /* 16 bit id */
262262
*dnsp++ = 0;
@@ -284,7 +284,7 @@ static size_t doh_encode(const char *host,
284284
labellen = strlen(hostp);
285285
if(labellen > 63)
286286
/* too long label, error out */
287-
return DOH_DNS_BAD_LABEL;
287+
return 0;
288288
*dnsp++ = (unsigned char)labellen;
289289
memcpy(dnsp, hostp, labellen);
290290
dnsp += labellen;

0 commit comments

Comments
 (0)