1. 26 Mar, 2008 3 commits
    • Eric Wong's avatar
      notify: cleanups · 232c9f6c
      Eric Wong authored
      * move set_nonblock{,ing}() into utils.c since we use it
      elsewhere, too
      * add proper error checking to set_nonblocking()
      * use os_compat.h instead of individually #includ-ing system headers
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@7217 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      232c9f6c
    • Eric Wong's avatar
      networking: more assertions and cleanups to size_t/unsigned changes · 99468b85
      Eric Wong authored
      Basically, I don't trust myself nor Max to not have bugs in our
      code when switching over to unsigned types, so I've added more
      assertions which will hopefully trip and force us to fix these
      bugs before somebody can exploit them :)
      
      Some cleanups for parameter parsing using strtol
      and error reporting to the user.  Also, fix some completely
      garbled indentation in inputStream_http.c
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@7209 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      99468b85
    • Max Kellermann's avatar
      use size_t · 27f12c17
      Max Kellermann authored
      When dealing with in-memory lengths, the standard type "size_t" should
      be used.  Missing one can be quite dangerous, because an attacker
      could provoke an integer under-/overflow, which may provide an attack
      vector.
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@7205 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      27f12c17
  2. 05 Feb, 2008 1 commit
  3. 03 Jan, 2008 1 commit
    • Eric Wong's avatar
      Cleanup #includes of standard system headers and put them in one place · cb8f1af3
      Eric Wong authored
      This will make refactoring features easier, especially now that
      pthreads support and larger refactorings are on the horizon.
      
      Hopefully, this will make porting to other platforms (even
      non-UNIX-like ones for masochists) easier, too.
      
      os_compat.h will house all the #includes for system headers
      considered to be the "core" of MPD.  Headers for optional
      features will be left to individual source files.
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@7130 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      cb8f1af3
  4. 28 Nov, 2007 2 commits
  5. 18 Nov, 2007 1 commit
  6. 08 Sep, 2007 1 commit
    • Eric Wong's avatar
      inputStream_http: signal the server to close after all requests · 30ed6bcf
      Eric Wong authored
      We want the partial content goodies of HTTP/1.1 without
      requiring persistent connections.  Persistent connections across
      multiple HTTP requests don't really help in the case of MPD,
      either, because our content is usually big and heavy.
      
      Note: this puts MPD at the hands of the server to correctly
      close() the TCP connection we're using.  If we connect to a
      rogue server that keeps the connection alive even when request
      not to, we'll spin :(  However, encountering such a server
      is very unlikely...
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@6867 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      30ed6bcf
  7. 27 Aug, 2007 1 commit
  8. 09 Jun, 2007 2 commits
  9. 04 Jun, 2007 1 commit
  10. 03 Jun, 2007 1 commit
  11. 02 Jun, 2007 2 commits
  12. 26 May, 2007 1 commit
  13. 05 Apr, 2007 1 commit
  14. 19 Feb, 2007 2 commits
    • Eric Wong's avatar
      inputStream_http: cleanup GET request code (finishHTTPInit) · 772dc6bc
      Eric Wong authored
      Avoid unnecessary memset to zero, snprintf always puts a
      trailing '\0'.  We also have no need to subtract one from the
      buffer we're snprintf-ing it to.
      
      We also check the return value of snprintf to ensure it's not
      too long.  I have a feeling we might as well avoid snprintf
      altogether so we don't have to worry about buffer sizing/stack
      overflow and just do a bunch of write(2)s, letting Nagle sort it
      out...
      
      Also, centralize some of the exit error handling in with
      goto.  This makes the code a bit more consistent and
      maintainable as well as reducing code and binary size.
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@5395 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      772dc6bc
    • Eric Wong's avatar
      inputStream_http: fix HTTP seeking · 93726921
      Eric Wong authored
      We need to identify ourselves as HTTP/1.1 so Range: works;
      and so the server can return HTTP/1.1 instead of HTTP/1.0.
      
      Tested against lighttpd 1.4.13
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@5394 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      93726921
  15. 06 Feb, 2007 1 commit
  16. 14 Jan, 2007 2 commits
  17. 23 Dec, 2006 1 commit
  18. 26 Aug, 2006 1 commit
    • Eric Wong's avatar
      Replace strdup and {c,re,m}alloc with x* variants to check for OOM errors · 90847fc8
      Eric Wong authored
      I'm checking for zero-size allocations and assert()-ing them,
      so we can more easily get backtraces and debug problems, but we'll
      also allow -DNDEBUG people to live on the edge if they wish.
      
      We do not rely on errno when checking for OOM errors because
      some implementations of malloc do not set it, and malloc
      is commonly overridden by userspace wrappers.
      
      I've spent some time looking through the source and didn't find any
      obvious places where we would explicitly allocate 0 bytes, so we
      shouldn't trip any of those assertions.
      
      We also avoid allocating zero bytes because C libraries don't
      handle this consistently (some return NULL, some not); and it's
      dangerous either way.
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@4690 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      90847fc8
  19. 30 Jul, 2006 1 commit
    • Eric Wong's avatar
      remove clumsy strncpy use · 263a9d58
      Eric Wong authored
      strncpy isn't really safe because it doesn't guarantee null termination,
      and we have had to work around it in several places.
      strlcpy (from OpenBSD) isn't great, either because it often leaves
      errors going unchecked (by truncating strings).
      
      So we'll add the pathcpy_trunc() function with is basically strlcpy
      with a hardcoded MAXPATHLEN as the limit, and we'll acknowledge
      truncation since we only work on paths and MAXPATHLEN should be
      set correctly by the system headers[1].
      
      file-specific notes:
      
      inputStream_http:
      eyeballing the changes here, it seems to look alright but I
      haven't actually tested it myself.
      
      ls:
      don't even bother printing a file if the filename is too long
      (and when is it ever?) since we won't be able to read it anyways.
      
      metadataChunk:
      it's only metadata, and it's only for showin the user, so truncating
      it here souldn't be a big issue.
      memset to zero in init is unecessary, so lets not waste cycles
      
      [1] - If the system headers are screwed up, then we're majorly
      screwed regardless of what we do :x
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@4491 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      263a9d58
  20. 20 Jul, 2006 2 commits
  21. 17 Jul, 2006 1 commit
    • Eric Wong's avatar
      sparse: ANSI-fy function declarations · a234780a
      Eric Wong authored
      These are just warnings from sparse, but it makes the output
      easier to read.  I ran this through a quick perl script, but
      of course verified the output by looking at the diff and making
      sure the thing still compiles.
      
      here's the quick perl script I wrote to generate this patch:
      ----------- 8< -----------
      use Tie::File;
      defined(my $pid = open my $fh, '-|') or die $!;
      if (!$pid) {
      open STDERR, '>&STDOUT' or die $!;
      exec 'sparse', @ARGV or die $!;
      }
      my $na = 'warning: non-ANSI function declaration of function';
      while (<$fh>) {
      print STDERR $_;
      if (/^(.+?\.[ch]):(\d+):(\d+): $na '(\w+)'/o) {
      my ($f, $l, $pos, $func) = ($1, $2, $3, $4);
      $l--;
      tie my @x, 'Tie::File', $f or die "$!: $f";
      print '-', $x[$l], "\n";
      $x[$l] =~ s/\b($func\s*)\(\s*\)/$1(void)/;
      print '+', $x[$l], "\n";
      untie @x;
      }
      }
      
      git-svn-id: https://svn.musicpd.org/mpd/trunk@4378 09075e82-0dd4-0310-85a5-a0d7c8717e4f
      a234780a
  22. 14 Jul, 2006 1 commit
  23. 13 Jul, 2006 1 commit
  24. 21 May, 2006 1 commit
  25. 14 May, 2006 1 commit
  26. 16 Mar, 2006 1 commit
  27. 15 Mar, 2006 1 commit
  28. 17 Apr, 2005 1 commit
  29. 23 Jan, 2005 1 commit
  30. 20 Nov, 2004 1 commit
  31. 05 Nov, 2004 1 commit
  32. 02 Nov, 2004 1 commit