| 55 | } |
| 56 | |
| 57 | static bool version_valid(const char *version) { |
| 58 | size_t length = 0; |
| 59 | if (!bounded_length(version, CBM_DAEMON_VERSION_TEXT_SIZE, &length) || length == 0) { |
| 60 | return false; |
| 61 | } |
| 62 | /* Version text reaches stderr and a persistent JSON log. Keep it printable |
| 63 | * ASCII so an untrusted HELLO cannot inject terminal control sequences or |
| 64 | * malformed UTF-8 into either diagnostic channel. */ |
| 65 | for (size_t i = 0; i < length; i++) { |
| 66 | unsigned char ch = (unsigned char)version[i]; |
| 67 | if (ch < 0x20 || ch > 0x7e) { |
| 68 | return false; |
| 69 | } |
| 70 | } |
| 71 | return true; |
| 72 | } |
| 73 | |
| 74 | static bool fingerprint_valid(const char *fingerprint) { |
| 75 | size_t length = 0; |
no test coverage detected