1. 07 Nov, 2013 1 commit
  2. 18 Sep, 2013 1 commit
    • Christian Hesse's avatar
      dload: avoid renaming files downloaded via sync operations · 3b3152fc
      Christian Hesse authored and Allan McRae's avatar Allan McRae committed
      If the server redirects from ${repo}.db to ${repo}.db.tar.gz pacman gets
      this wrong: It saves to new filename and fails when accessing
      We need the remote filename only when downloading remote files with
      pacman's -U operation. This introduces a new field 'trust_remote_name'
      to payload. If set pacman downloads to the filename given by the server.
      The field trust_remote_name is set in alpm_fetch_pkgurl().
      Fixes FS#36791 ([pacman] downloads to wrong filename with redirect).
      [dave: remove redundant assignment leading to memory leak]
      Signed-off-by: Allan McRae's avatarAllan McRae <allan@archlinux.org>
  3. 21 Aug, 2013 1 commit
  4. 22 Jul, 2013 1 commit
  5. 05 Jul, 2013 1 commit
    • Dave Reisner's avatar
      do not check error from close(2) · eb19d41d
      Dave Reisner authored and Allan McRae's avatar Allan McRae committed
      On operating systems we support, the behavior is always such that the
      kernel will do the right thing as far as invalidating the file
      descriptor, regardless of the eventual return value. Therefore,
      potentially looping and calling close multiple times is wrong.
      At best, we call close again on an invalid FD and throw a spurious EBADF
      error. At worst, we might close an FD which doesn't belong to us when a
      multi-threaded application opens its own file descriptor between
      iterations of the loop.
      Signed-off-by: default avatarDave Reisner <dreisner@archlinux.org>
      Signed-off-by: Allan McRae's avatarAllan McRae <allan@archlinux.org>
  6. 24 Feb, 2013 1 commit
  7. 29 Jan, 2013 2 commits
  8. 17 Jan, 2013 1 commit
  9. 03 Jan, 2013 1 commit
  10. 14 Dec, 2012 1 commit
  11. 20 May, 2012 1 commit
  12. 09 Apr, 2012 1 commit
    • Dan McGee's avatar
      Fix issues with unintialized variable value usage · ded66fbb
      Dan McGee authored
      Detected by clang scan-build static code analyzer.
      * Don't attempt to free an uninitialized gpgme key variable
      * Initialize answer variable before asking frontend a question
      * Pass by reference instead of value if uninitialized fields are
        possible in download signal handler code
      * Ensure we never call strlen() on NULL payload->remote_name value
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
  13. 15 Mar, 2012 1 commit
  14. 20 Feb, 2012 1 commit
    • Nagy Gabor's avatar
      Print error message when to-be-downloaded file cannot be created · 31d95b86
      Nagy Gabor authored
      It can happen that the to-be-downloaded file cannot be created in cachedir.
      For example, I am an -Sup user, and it is comfortable to set --cachedir to
      /mnt/pendrive, which is a FAT filesystem, so files like
      capseo-1:0.3-2-i686.pkg.tar.xz cannot be downloaded to there.
      Before this patch, pacman didn't give clear output about what happens when
      the download code could not create the necessary file. This can be confusing
      with -Su. An example output:
      $ sudo pacman -S capseo bochs --cachedir /c/TEMP
      resolving dependencies...
      looking for inter-conflicts...
      Targets (2): bochs-2.4.6-1  capseo-1:0.3-2
      Total Download Size:    0.61 MiB
      Total Installed Size:   2.61 MiB
      Proceed with installation? [Y/n]
      :: Retrieving packages from extra...
      warning: failed to retrieve some files from extra
       bochs-2.4.6-1-i686       611.5 KiB   118K/s 00:05 [------------------]  97%
      error: failed to commit transaction (unexpected error)
      Errors occurred, no packages were upgraded.
      After the patch, pacman will give more informative error message (and
      pm_errno is set properly):
      error: could not open file '/c/TEMP/capseo-1:0.3-2-i686.pkg.tar.xz.part': Invalid argument
      error: failed to commit transaction (failed to retrieve some files)
      Unfortunately, the "could not open file" error message is printed for
      every mirror (that can be dozens of lines), which is ugly, but at least
      informative... Without modifying the download logic (for example, by
      introducing -2 return value for _alpm_download() to indicate giving up),
      this ugliness cannot be eliminated.
      Signed-off-by: default avatarNagy Gabor <ngaba@bibl.u-szeged.hu>
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
  15. 14 Feb, 2012 1 commit
  16. 23 Jan, 2012 2 commits
  17. 19 Jan, 2012 2 commits
  18. 22 Dec, 2011 1 commit
    • Dave Reisner's avatar
      include config.h via Makefiles · d6ccd443
      Dave Reisner authored
      Ensures that config.h is always ordered correctly (first) in the
      includes. Also means that new source files get this for free without
      having to remember to add it.
      We opt for -imacros over -include as its more portable, and the
      added constraint by -imacros doesn't bother us for config.h.
      This also touches the HACKING file to remove the explicit mention of
      config.h as part of the includes.
      Signed-off-by: default avatarDave Reisner <dreisner@archlinux.org>
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
  19. 05 Dec, 2011 1 commit
  20. 01 Nov, 2011 1 commit
  21. 27 Oct, 2011 2 commits
  22. 24 Oct, 2011 1 commit
    • Dan McGee's avatar
      Add more logging to download code · 58530251
      Dan McGee authored
      This adds a logger to the CURLE_OK case so we can always know the return
      code if it was >= 400, and debug log it regardless. Also adjust another
      logger to use the cURL error message directly, as well as use fstat()
      when we have an open file handle rather than stat().
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
  23. 13 Oct, 2011 1 commit
    • Dan McGee's avatar
      curl_gethost() potential bug fixups · 86bc3641
      Dan McGee authored
      This is in the realm of "probably not going to happen", but if someone
      were to translate "disk" to a string longer than 256 characters, we
      would have a smashed/corrupted stack due to our unchecked strcpy() call.
      Rework the function to always length-check the value we copy into the
      hostname buffer, and do it with memcpy rather than the more cumbersome
      and unnecessary snprintf.
      Finally, move the magic 256 value into a constant and pass it into the
      function which is going to get inlined anyway.
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
  24. 11 Oct, 2011 1 commit
  25. 29 Sep, 2011 1 commit
  26. 28 Sep, 2011 3 commits
    • Dan McGee's avatar
      Refactor download payload reset and free · e0acf2f1
      Dan McGee authored
      This was done to squash a memory leak in the sync database download
      code. When we downloaded a database and then reused the payload struct,
      we could find ourselves calling get_fullpath() for the signatures and
      overwriting non-freed values we had left over from the database
      Refactor the payload_free function into a payload_reset function that we
      can call that does NOT free the payload itself, so we can reuse payload
      structs. This also allows us to move the payload to the stack in some
      call paths, relieving us of the need to alloc space.
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
    • Dan McGee's avatar
      Initialize cURL library on first use · 9a58d5c6
      Dan McGee authored
      Rather than always initializing it on any handle creation. There are
      several frontend operations (search, info, etc.) that never need the
      download code, so spending time initializing this every single time is a
      bit silly. This makes it a bit more like the GPGME code init path.
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
    • Dan McGee's avatar
      Fix memory leak in download payload->remote_name · f66f9f11
      Dan McGee authored
      In the sync code, we explicitly allocated a string for this field, while
      in the dload code itself it was filled in with a pointer to another
      string. This led to a memory leak in the sync download case.
      Make remote_name non-const and always explicitly allocate it. This patch
      ensures this as well as uses malloc + snprintf (rather than calloc) in
      several codepaths, and eliminates the only use of PATH_MAX in the
      download code.
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>
  27. 18 Sep, 2011 2 commits
  28. 12 Sep, 2011 1 commit
  29. 06 Sep, 2011 3 commits
  30. 29 Aug, 2011 1 commit
  31. 25 Aug, 2011 1 commit
    • Dan McGee's avatar
      Finish large file download attack prevention · f7a3c4c8
      Dan McGee authored
      This handles the no Content-Length header problem as stated in the
      comments of FS#23413. We add a quick check to the callback that will
      force an abort if the downloaded data exceeds the payload size, and then
      check for this error in the post-download cleanup code.
      Signed-off-by: default avatarDan McGee <dan@archlinux.org>