| 109 | } |
| 110 | |
| 111 | bool printwire_utf8_array(const char *fieldname, const u8 **cursor, size_t *plen, size_t len) |
| 112 | { |
| 113 | struct utf8_state utf8 = UTF8_STATE_INIT; |
| 114 | const char *p = (const char *)*cursor; |
| 115 | bool char_done = true; |
| 116 | |
| 117 | printf("["); |
| 118 | for (size_t i = 0; i < len; i++) { |
| 119 | if (!p[i]) { |
| 120 | if (!memeqzero(p+i, len-i)) { |
| 121 | printf(" **INVALID PADDING** "); |
| 122 | goto hexdump; |
| 123 | } |
| 124 | break; |
| 125 | } |
| 126 | if (utf8_decode(&utf8, p[i])) { |
| 127 | if (errno != 0) { |
| 128 | printf(" **INVALID UTF-8** "); |
| 129 | goto hexdump; |
| 130 | } |
| 131 | char_done = true; |
| 132 | } else { |
| 133 | /* Don't allow unprintable characters */ |
| 134 | if (utf8.total_len == 1 && !cisprint(utf8.c)) { |
| 135 | printf(" **UNPRINTABLE CHARACTER** "); |
| 136 | goto hexdump; |
| 137 | } |
| 138 | char_done = false; |
| 139 | } |
| 140 | } |
| 141 | if (!char_done) { |
| 142 | printf(" **INCOMPLETE UTF-8** "); |
| 143 | goto hexdump; |
| 144 | } |
| 145 | printf("%.*s ", (int)len, p); |
| 146 | |
| 147 | hexdump: |
| 148 | if (!print_hexstring(cursor, plen, len)) |
| 149 | return false; |
| 150 | printf(" ]\n"); |
| 151 | return true; |
| 152 | } |
| 153 | |
| 154 | static bool printwire_addresses(const u8 **cursor, size_t *plen, size_t len) |
| 155 | { |
no test coverage detected