8f3d4b6758
While the current code only ever calls try_connect() with the input argument 'device' in the range of 0 and MAX_DEVICES, this adds a check to ensure that future code does not break the following sprintf. In addition, use snprintf instead of sprintf to ensure that if anything breaks, the sprintf does not lead to memory corruption. Again, the new check should already make sure of that, but the additional effort of using snprintf instead of sprintf is so low that it is worth to have a little more security in the future.