As read_int_bounded but for varint-encoded values. */
| 1902 | |
| 1903 | /* As read_int_bounded but for varint-encoded values. */ |
| 1904 | int32 read_varint_bounded(int f, int32 lo, int32 hi, const char *what) |
| 1905 | { |
| 1906 | int32 v = read_varint(f); |
| 1907 | if (v < lo || v > hi) { |
| 1908 | rprintf(FERROR, "wire value %s out of range: %ld not in [%ld,%ld] [%s]\n", |
| 1909 | what, (long)v, (long)lo, (long)hi, who_am_i()); |
| 1910 | exit_cleanup(RERR_PROTOCOL); |
| 1911 | } |
| 1912 | return v; |
| 1913 | } |
| 1914 | |
| 1915 | /* Read a varint that will be used as a size_t. Rejects negative values |
| 1916 | * (which would wrap to ~SIZE_MAX) and values exceeding the supplied max. */ |
no test coverage detected