This repository has been archived by the owner on Jun 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Add res_randomid #8
Comments
This is a known issue, I recently got access to a Linux distro with a musl based libc which lacks res_randomid(), this will be worked out in a very near future. |
I googled and found glibc's implementation: u_int
res_randomid(void) {
return 0xffff & __getpid();
} and they call it random??? 👎 Good news is that it should be trivial to fix. |
Quick and dirty hack. We probably want something better though. diff --git a/configure.ac b/configure.ac
index 10aff04..07e149f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -456,6 +456,7 @@ AC_CHECK_FUNCS([ \
issetugid \
memmove \
reallocarray \
+ res_randomid \
snprintf \
strdup \
strerror \
diff --git a/src/asr_private.h b/src/asr_private.h
index 0960e37..254e83e 100644
--- a/src/asr_private.h
+++ b/src/asr_private.h
@@ -365,3 +365,7 @@ extern FILE * asr_debug;
asr_statestr((a)->as_state), \
asr_statestr((s))); \
(a)->as_state = (s); } while (0)
+
+#ifndef HAVE_RES_RANDOMID
+#define res_randomid(x) (0xfff & getpid())
+#endif |
neither @ericfaurot or I feel comfortable with mimic-ing the glibc dumb res_randomid() with a little bit of work, we should be able to bring an arc4random()-based one relying on the arc4random() from the portable layer. |
That was what I wanted to hear. Thanks! |
this has been opened for way too long, I've merged a diff very similar to yours, eric can improve further when he gets a better idea. thanks ! |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
libasr has copied many resolver functions from OpenBSD. However the function res_randomid(), which is used in res_send_async() and res_mkquery() seems to have been forgotten.
Because of this libasr currently only works with glibc and uclibc>=0.9.33 as these libc's provide the function. It however seems to be a non-standard function with no real documentation.
Could res_randomid() be provided, inclusion possibly depending on a configure test?
The text was updated successfully, but these errors were encountered: