The original bug here is that you can get duplicate truncated device names when you are enumerating core audio devices (input and/or output) with SOX via the hack here
sox -V6 -n -t coreaudio junkname
This is a problem when you want to USE one of these devices in a SOX command, and sox gets confused about which one you mean, since multiple device IDs match the truncated string (as noted in coreaudio.c). I believe that the root problem here is in part or in whole that the API that sox's coreaudio.c file is using has long been deprecated, and so is very unreliable when it comes to getting truncated names out on MacOS . I believe if the APIs were updated, per https://developer.apple.com/library/archive/technotes/tn2223/index.html then this may solve the truncation / duplication issue as a happy side effect.
As a bonus, SOX would no longer be using unreliable APIs.
This issue is not due to the old API, but in src/coreaudio.c:155.
This is caused by specifying "property_size", instead of 256, which is the length of "name".
The property_size is value for length of device structure list.
This is also a security issue sice if there are many devices and property_size may exceed 256.
Also, property_size is not initialized in the for loop, so if there are multiple devices, the names will become shorter and shorter.