| 332 | } |
| 333 | |
| 334 | static int icmap_check_value_len(const void *value, size_t value_len, icmap_value_types_t type) |
| 335 | { |
| 336 | |
| 337 | if (value_len > ICMAP_MAX_VALUE_LEN) { |
| 338 | return (-1); |
| 339 | } |
| 340 | |
| 341 | if (type != ICMAP_VALUETYPE_STRING && type != ICMAP_VALUETYPE_BINARY) { |
| 342 | if (icmap_get_valuetype_len(type) == value_len) { |
| 343 | return (0); |
| 344 | } else { |
| 345 | return (-1); |
| 346 | } |
| 347 | } |
| 348 | |
| 349 | if (type == ICMAP_VALUETYPE_STRING) { |
| 350 | /* |
| 351 | * value_len can be shorter then real string length, but never |
| 352 | * longer (+ 1 is because of 0 at the end of string) |
| 353 | */ |
| 354 | if (value_len > strlen((const char *)value) + 1) { |
| 355 | return (-1); |
| 356 | } else { |
| 357 | return (0); |
| 358 | } |
| 359 | } |
| 360 | |
| 361 | return (0); |
| 362 | } |
| 363 | |
| 364 | static int icmap_item_eq(const struct icmap_item *item, const void *value, size_t value_len, icmap_value_types_t type) |
| 365 | { |
no test coverage detected