bug-wget
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-wget] Writing to a Read-Only directory


From: Gisle Vanem
Subject: Re: [Bug-wget] Writing to a Read-Only directory
Date: Wed, 10 Feb 2016 18:58:35 +0100
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.1

Tim Ruehsen wrote:

> I fixed that issue in a tiny commit that I just pushed.
> 
> BTW, I remember we had this or a similar issue before... though I couldn't 
> find it with a quick search.

Sorry Tim, the error-message is still the same.
There are several return-paths in logprintf() where 'errno_saved'
isn't restored. This is what I did to prevent losing 'errno':

--- a/log.c 2016-02-10 18:09:07
+++ b/log.c 2016-02-10 18:53:25
@@ -277,21 +277,21 @@
     {                                           \
     case LOG_PROGRESS:                          \
       if (!opt.show_progress)                   \
-        return;                                 \
+        goto quit;                              \
       break;                                    \
     case LOG_ALWAYS:                            \
       break;                                    \
     case LOG_NOTQUIET:                          \
       if (opt.quiet)                            \
-        return;                                 \
+        goto quit;                              \
       break;                                    \
     case LOG_NONVERBOSE:                        \
       if (opt.verbose || opt.quiet)             \
-        return;                                 \
+        goto quit;                              \
       break;                                    \
     case LOG_VERBOSE:                           \
       if (!opt.verbose)                         \
-        return;                                 \
+        goto quit;                              \
     }

 /* Returns the file descriptor for logging.  This is LOGFP, except if
@@ -351,6 +351,7 @@
 {
   FILE *fp;
   FILE *warcfp;
+  int errno_saved = errno;

   check_redirect_output ();
   if (o == LOG_PROGRESS)
@@ -359,7 +360,7 @@
     fp = get_log_fp ();

   if (fp == NULL)
-    return;
+    goto quit;

   warcfp = get_warc_log_fp ();
   CHECK_VERBOSE (o);
@@ -373,6 +374,9 @@
     logflush ();
   else
     needs_flushing = true;
+
+quit:
+  errno = errno_saved;
 }

 struct logvprintf_state {
@@ -547,7 +551,8 @@

   check_redirect_output ();
   if (inhibit_logging)
-    return;
+    goto quit;
+
   CHECK_VERBOSE (o);

   xzero (lpstate);
@@ -563,6 +568,7 @@
     }
   while (!done);

+quit:
   errno = errno_saved;
 }

------------------------

The question is if errno caused by logprintf() gets lost and
caused havoc elsewhere!?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]