Given a sequence of bytes and the number of these that we were able to * parse, verify that upgrade bodies are correct. */
| 2388 | * parse, verify that upgrade bodies are correct. |
| 2389 | */ |
| 2390 | void |
| 2391 | upgrade_message_fix(char *body, const size_t nread, const size_t nmsgs, ...) { |
| 2392 | va_list ap; |
| 2393 | size_t i; |
| 2394 | size_t off = 0; |
| 2395 | |
| 2396 | va_start(ap, nmsgs); |
| 2397 | |
| 2398 | for (i = 0; i < nmsgs; i++) { |
| 2399 | struct message *m = va_arg(ap, struct message *); |
| 2400 | |
| 2401 | off += strlen(m->raw); |
| 2402 | |
| 2403 | if (m->upgrade) { |
| 2404 | off -= strlen(m->upgrade); |
| 2405 | |
| 2406 | /* Check the portion of the response after its specified upgrade */ |
| 2407 | if (!check_str_eq(m, "upgrade", body + off, body + nread)) { |
| 2408 | abort(); |
| 2409 | } |
| 2410 | |
| 2411 | /* Fix up the response so that message_eq() will verify the beginning |
| 2412 | * of the upgrade */ |
| 2413 | *(body + nread + strlen(m->upgrade)) = '\0'; |
| 2414 | messages[num_messages -1 ].upgrade = body + nread; |
| 2415 | |
| 2416 | va_end(ap); |
| 2417 | return; |
| 2418 | } |
| 2419 | } |
| 2420 | |
| 2421 | va_end(ap); |
| 2422 | printf("\n\n*** Error: expected a message with upgrade ***\n"); |
| 2423 | |
| 2424 | abort(); |
| 2425 | } |
| 2426 | |
| 2427 | static void |
| 2428 | print_error (const char *raw, size_t error_location) |
no test coverage detected