MCPcopy Create free account
hub / github.com/ElementsProject/lightning / printwire_utf8_array

Function printwire_utf8_array

devtools/print_wire.c:162–203  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

160}
161
162bool 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
198hexdump:
199 if (!print_hexstring(cursor, plen, len))
200 return false;
201 printf(" ]\n");
202 return true;
203}
204
205static bool printwire_addresses(const u8 **cursor, size_t *plen, size_t len)
206{

Callers 1

printwire_u8_arrayFunction · 0.85

Calls 4

memeqzeroFunction · 0.85
utf8_decodeFunction · 0.85
cisprintFunction · 0.85
print_hexstringFunction · 0.85

Tested by

no test coverage detected