]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Use sysconf if needed to get ARG_MAX 10965/head
authorOtto <otto.moerbeek@open-xchange.com>
Mon, 8 Nov 2021 13:10:31 +0000 (14:10 +0100)
committerOtto <otto.moerbeek@open-xchange.com>
Mon, 8 Nov 2021 13:26:09 +0000 (14:26 +0100)
pdns/rec_channel.cc

index b87e551fb204eceb972c304511fecb32541bd243..7cc46b8bebebb1ea191ba4307feb0970b5f2479b 100644 (file)
@@ -165,6 +165,22 @@ static void waitForRead(int fd, unsigned int timeout, time_t start)
   }
 }
 
+static size_t getArgMax()
+{
+#if defined(ARG_MAX)
+  return ARG_MAX;
+#endif
+
+#if defined(_SC_ARG_MAX)
+  auto tmp = sysconf(_SC_ARG_MAX);
+  if (tmp != -1) {
+    return tmp;
+  }
+#endif
+  /* _POSIX_ARG_MAX */
+  return 4096;
+}
+
 RecursorControlChannel::Answer RecursorControlChannel::recv(int fd, unsigned int timeout)
 {
   // timeout covers the operation of all read ops combined
@@ -182,7 +198,7 @@ RecursorControlChannel::Answer RecursorControlChannel::recv(int fd, unsigned int
     throw PDNSException("Unable to receive length over control channel: " + stringerror());
   }
 
-  if (len > ARG_MAX) {
+  if (len > getArgMax()) {
     throw PDNSException("Length of control channel message too large");
   }