• Matt Stancliff's avatar
    Fix errno error buffers to not clobber errors · cc202324
    Matt Stancliff authored
    The strerror_r API has two flavors depending on system options.
    
    The bad flavor uses a static buffer for returning results, so if
    you save the pointer from strerror_r, the string you're referencing
    becomes useless if anybody else calls strerror_r again
    
    The good flavor does what you expect: it writes the error to your buffer.
    
    This commit uses strerror_r directly if it's a good version or copies
    the static buffer into our private buffer if it's a bad version.
    
    Thanks to gemorin for explaining the problem and drafting a fix.
    
    Fixes #239
    cc202324
net.c 12.6 KB