weirdo hack to fix debian bug report 278691:
authorDaniel Stenberg <daniel@haxx.se>
Mon, 8 Nov 2004 19:41:28 +0000 (19:41 +0000)
committerDaniel Stenberg <daniel@haxx.se>
Mon, 8 Nov 2004 19:41:28 +0000 (19:41 +0000)
'curl -v writes debugging to its network socket if stderr is closed'

CHANGES
configure.ac
src/config.h.in
src/main.c

diff --git a/CHANGES b/CHANGES
index e9ea6a3..15c3ceb 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -6,6 +6,15 @@
 
                                   Changelog
 
+Daniel (8 November 2004)
+- Ian Gulliver reported in debian bug report #278691: if curl is invoked in an
+  environment where stderr is closed the -v output will still be sent to file
+  descriptor 2 which then might be the network socket handle! Now we have a
+  weird hack instead that attempts to make sure that file descriptor 2 is
+  opened (with a call to pipe()) before libcurl is called to do the transfer.
+  configure now checks for pipe() and systems without pipe don't get the weird
+  hack done.
+
 Daniel (5 November 2004)
 - Tim Sneddon made libcurl send no more than 64K in a single first chunk when
   doing a huge POST on VMS, as this is a system limitation. Default on general
index 091c869..6215495 100644 (file)
@@ -1227,6 +1227,7 @@ AC_CHECK_FUNCS( strtoll \
                 basename \
                 setlocale \
                 ftruncate \
+                pipe \
                 poll,
 dnl if found
 [],
index 45eab36..5636cbe 100644 (file)
 
 /* Define to 1 if you have the `gettimeofday' function. */
 #undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the `ftruncate' function. */
+#undef HAVE_FTRUNCATE
+
+/* Define to 1 if you have the `pipe' function. */
+#undef HAVE_PIPE
index 2fdb1eb..4f6c62a 100644 (file)
@@ -3771,12 +3771,35 @@ operate(struct Configurable *config, int argc, char *argv[])
   return res;
 }
 
+static void checkfds(void);
+
+static void checkfds(void)
+{
+#ifdef HAVE_PIPE
+  int fd[2] = { STDIN_FILENO, STDIN_FILENO };
+  while( fd[0] == STDIN_FILENO ||
+         fd[0] == STDOUT_FILENO ||
+         fd[0] == STDERR_FILENO ||
+         fd[1] == STDIN_FILENO ||
+         fd[1] == STDOUT_FILENO ||
+         fd[1] == STDERR_FILENO )
+    pipe(fd);
+
+  close(fd[0]);
+  close(fd[1]);
+#endif
+}
+
+
+
 int main(int argc, char *argv[])
 {
   int res;
   struct Configurable config;
   memset(&config, 0, sizeof(struct Configurable));
 
+  checkfds();
+
   res = operate(&config, argc, argv);
   free_config_fields(&config);