Skip to content
  • David Ward's avatar
    Use snprintf() instead of strncpy() for space-padded strings · b3d105cb
    David Ward authored
    The output from the SCSI inquiry command uses fixed-length space-padded
    strings, which are copied into null-terminated strings before use.
    
    This is currently done using strncpy(), with the count parameter set to
    the string's fixed length. Because a null terminator is not encountered
    in the input, strncpy() does not write one in the output, and GCC warns
    about potential string truncation. A null terminator is added manually,
    but this is error prone (as shown by the fix for the microtek backend).
    
    Use snprintf() instead, which guarantees a null-terminated result and
    resolves the warnings from GCC.
    b3d105cb