| 604 | } |
| 605 | |
| 606 | static bool gd_table_rows(gd_context_t *g, int index, bool present) { |
| 607 | uint64_t rows = 0; |
| 608 | const gd_table_t *table = &gd_tables[index]; |
| 609 | if (present) { |
| 610 | if (!gd_prepare(g, table->row_query)) { |
| 611 | return false; |
| 612 | } |
| 613 | if (sqlite3_column_count(g->stmt) != table->column_count) { |
| 614 | return gd_fail(g, CBM_STORE_GRAPH_DIGEST_SCHEMA); |
| 615 | } |
| 616 | int rc; |
| 617 | while ((rc = gd_step(g)) == SQLITE_ROW) { |
| 618 | if (!gd_check(g)) { |
| 619 | return false; |
| 620 | } |
| 621 | if (g->rows == g->limits.max_rows || g->rows == UINT64_MAX || rows == UINT64_MAX) { |
| 622 | return gd_fail(g, CBM_STORE_GRAPH_DIGEST_LIMIT); |
| 623 | } |
| 624 | if (index == GD_STORE_META && !gd_generation(g)) { |
| 625 | return false; |
| 626 | } |
| 627 | if (!gd_u8(g, 0x21) || !gd_u32(g, (uint32_t)table->column_count)) { |
| 628 | return false; |
| 629 | } |
| 630 | for (int i = 0; i < table->column_count; i++) { |
| 631 | if (!gd_column_value(g, i, &table->columns[i])) { |
| 632 | return false; |
| 633 | } |
| 634 | } |
| 635 | rows++; |
| 636 | g->rows++; |
| 637 | } |
| 638 | if (rc != SQLITE_DONE || !gd_finalize(g)) { |
| 639 | return false; |
| 640 | } |
| 641 | if (index == GD_STORE_META && (!g->have_uid || !g->have_counter)) { |
| 642 | return gd_fail(g, CBM_STORE_GRAPH_DIGEST_SCHEMA); |
| 643 | } |
| 644 | } |
| 645 | return gd_u8(g, 0x22) && gd_u64(g, rows); |
| 646 | } |
| 647 | |
| 648 | static bool gd_project_argument(gd_context_t *g, const unsigned char *project, size_t length) { |
| 649 | while (length) { |
no test coverage detected