summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormirabilos <m@mirbsd.org>2021-08-09 03:30:47 +0200
committermirabilos <mirabilos@evolvis.org>2021-08-09 03:30:47 +0200
commit8d9634346817a65f4ec927f3bc87a2dded7791bf (patch)
treef96d6fa25446afd3c70e606d72dab3b9a88c44d8
parent2bf4991c4dd7b50b74656011dea9c40464ff390c (diff)
libc/inet/resolv.c: use dn_{comp,expand} for __{en,de}code_dotted
Minimal-invasive change: just ifdeffing away the older code. There is no reason to have two different sets of functions doing the same thing, one used in half the code and another, doing less escaping, in the other half; just use one. Signed-off-by: mirabilos <mirabilos@evolvis.org>
-rw-r--r--libc/inet/resolv.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libc/inet/resolv.c b/libc/inet/resolv.c
index ed2e0d2fa..b2cca27d1 100644
--- a/libc/inet/resolv.c
+++ b/libc/inet/resolv.c
@@ -11,6 +11,7 @@
/*
* Portions Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
+ * Portions Copyright © 2021 mirabilos <m@mirbsd.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -559,6 +560,9 @@ void __decode_header(unsigned char *data,
the data */
int __encode_dotted(const char *dotted, unsigned char *dest, int maxlen)
{
+#ifndef WHY_UCLIBC_WHY_DID_YOU_DO_THIS
+ return (dn_comp(dotted, dest, maxlen, NULL, NULL));
+#else
unsigned used = 0;
while (dotted && *dotted) {
@@ -587,6 +591,7 @@ int __encode_dotted(const char *dotted, unsigned char *dest, int maxlen)
dest[used++] = 0;
return used;
+#endif
}
#endif /* L_encoded */
@@ -601,6 +606,9 @@ int __decode_dotted(const unsigned char *packet,
char *dest,
int dest_len)
{
+#ifndef WHY_UCLIBC_WHY_DID_YOU_DO_THIS
+ return (dn_expand(packet, packet + packet_len, packet + offset, dest, dest_len));
+#else
unsigned b;
bool measure = 1;
unsigned total = 0;
@@ -658,6 +666,7 @@ int __decode_dotted(const unsigned char *packet,
DPRINTF("Total decode len = %d\n", total);
return total;
+#endif
}
#endif /* L_decoded */