]> sjero.net Git - wget/commitdiff
Automated merge.
authorMicah Cowan <micah@cowan.name>
Sun, 13 Apr 2008 06:21:09 +0000 (23:21 -0700)
committerMicah Cowan <micah@cowan.name>
Sun, 13 Apr 2008 06:21:09 +0000 (23:21 -0700)
1  2 
src/ChangeLog
src/utils.c

diff --combined src/ChangeLog
index 734765582fcb3480b8e484018fa1dea57f39b9db,8865e5dd2f431fbd7281c6f470a233693a434831..871a82e79f6c68b27092360bcf9ef5c48d43e8ef
@@@ -1,11 -1,25 +1,23 @@@
 -2007-04-12  Micah Cowan  <micah@cowan.name>
 +2008-04-12  Rabin Vincent  <rabin@rab.in>
  
        * mswindows.c (fake_fork_child): Don't create a logfile for
        --background when --quiet is used, but not --server-response.
 -      Don't mention that we're backgrounding if --quiet is used. Based
 -      on a patch submitted by Rabin Vincent <rabin@rab.in>.  Fixes bug
 -      #20917.
 +      Fixes bug #20917.
  
        * utils.c (fork_to_background): Likewise.
  
+ 2008-04-12  Micah Cowan  <micah@cowan.name>
+       * utils.c (aprintf): Minor formatting changes to Alex's code (80-
+       column limit, concatenated string literals, avoiding nesting
+       levels), and removed invocation of free (since we're aborting
+       anyway).
+ 2008-04-11  Alexander Dergachev  <cy6erbr4in@gmail.com>
+       * utils.c (aprintf): Now we are setting limits (1 Mb) for text
+       buffer when we use non-C99 vsnprintf.
+       
  2008-04-11  Micah Cowan  <micah@cowan.name>
  
        * ftp.c (getftp, ftp_loop_internal): Don't append to an existing
diff --combined src/utils.c
index a8c5303862c5274dba500bbcab157ac5b251a641,df4ce20858849a5ba2b3db9ad754a1a97c1d1471..a4928dabacea525261ba3806dd8f34d80f89ad6e
@@@ -159,6 -159,13 +159,13 @@@ sepstring (const char *s
     vsnprintf until the correct size is found.  Since Wget also ships a
     fallback implementation of vsnprintf, this should be portable.  */
  
+ /* Constant is using for limits memory allocation for text buffer.
+    Applicable in situation when: vasprintf is not available in the system 
+    and vsnprintf return -1 when long line is truncated (in old versions of
+    glibc and in other system where C99 doesn`t support) */
+ #define FMT_MAX_LENGTH 1048576
  char *
  aprintf (const char *fmt, ...)
  {
    ret = vasprintf (&str, fmt, args);
    va_end (args);
    if (ret < 0 && errno == ENOMEM)
-     memfatal ("aprintf", UNKNOWN_ATTEMPTED_SIZE);  /* for consistency with xmalloc/xrealloc */
+     memfatal ("aprintf", UNKNOWN_ATTEMPTED_SIZE);  /* for consistency
+                                                       with xmalloc/xrealloc */
    else if (ret < 0)
      return NULL;
    return str;
        /* Else try again with a larger buffer. */
        if (n > -1)               /* C99 */
          size = n + 1;           /* precisely what is needed */
+       else if (size >= FMT_MAX_LENGTH)  /* We have a huge buffer, */
+         {                               /* maybe we have some wrong
+                                            format string? */
+           logprintf (LOG_ALWAYS, 
+                      _("%s: aprintf: text buffer is too big (%ld bytes), "
+                        "aborting.\n"),
+                      exec_name, size);  /* printout a log message */
+           abort ();                     /* and abort... */
+         }
        else
-         size <<= 1;             /* twice the old size */
+         {
+           /* else, we continue to grow our
+            * buffer: Twice the old size. */
+           size <<= 1;
+         }
        str = xrealloc (str, size);
      }
  #endif /* not HAVE_VASPRINTF */
@@@ -301,7 -322,14 +322,7 @@@ fork_to_background (void
    /* Whether we arrange our own version of opt.lfilename here.  */
    bool logfile_changed = false;
  
 -  if (opt.quiet && !opt.server_response)
 -    {
 -      /* Don't bother with a logfile, there are virtually no logs we
 -         issue in quiet mode. (Server responses in FTP are the
 -         exception, when enabled.) */
 -      log_close ();
 -    }
 -  if (!opt.lfilename)
 +  if (!opt.lfilename && (!opt.quiet || opt.server_response))
      {
        /* We must create the file immediately to avoid either a race
           condition (which arises from using unique_name and failing to
    else if (pid != 0)
      {
        /* parent, no error */
 -      if (!quiet)
 -        printf (_("Continuing in background, pid %d.\n"), (int) pid);
 +      printf (_("Continuing in background, pid %d.\n"), (int) pid);
        if (logfile_changed)
          printf (_("Output will be written to `%s'.\n"), opt.lfilename);
        exit (0);                 /* #### should we use _exit()? */