• 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
metadataChunk.c 2.54 KB