| 160 | } |
| 161 | |
| 162 | bool printwire_utf8_array(const char *fieldname, const u8 **cursor, size_t *plen, size_t len) |
| 163 | { |
| 164 | struct utf8_state utf8 = UTF8_STATE_INIT; |
| 165 | const char *p = (const char *)*cursor; |
| 166 | bool char_done = true; |
| 167 | |
| 168 | printf("["); |
| 169 | for (size_t i = 0; i < len; i++) { |
| 170 | if (!p[i]) { |
| 171 | if (!memeqzero(p+i, len-i)) { |
| 172 | printf(" **INVALID PADDING** "); |
| 173 | goto hexdump; |
| 174 | } |
| 175 | break; |
| 176 | } |
| 177 | if (utf8_decode(&utf8, p[i])) { |
| 178 | if (errno != 0) { |
| 179 | printf(" **INVALID UTF-8** "); |
| 180 | goto hexdump; |
| 181 | } |
| 182 | char_done = true; |
| 183 | } else { |
| 184 | /* Don't allow unprintable characters */ |
| 185 | if (utf8.total_len == 1 && !cisprint(utf8.c)) { |
| 186 | printf(" **UNPRINTABLE CHARACTER** "); |
| 187 | goto hexdump; |
| 188 | } |
| 189 | char_done = false; |
| 190 | } |
| 191 | } |
| 192 | if (!char_done) { |
| 193 | printf(" **INCOMPLETE UTF-8** "); |
| 194 | goto hexdump; |
| 195 | } |
| 196 | printf("%.*s ", (int)len, p); |
| 197 | |
| 198 | hexdump: |
| 199 | if (!print_hexstring(cursor, plen, len)) |
| 200 | return false; |
| 201 | printf(" ]\n"); |
| 202 | return true; |
| 203 | } |
| 204 | |
| 205 | static bool printwire_addresses(const u8 **cursor, size_t *plen, size_t len) |
| 206 | { |
no test coverage detected