* skips @count strings from the current position in a received binary packet * * @return: * 0: success * < 0: error, buffer limit reached */
| 292 | * < 0: error, buffer limit reached |
| 293 | */ |
| 294 | int bin_skip_str(bin_packet_t *packet, int count) |
| 295 | { |
| 296 | int i, len; |
| 297 | |
| 298 | for (i = 0; i < count; i++) { |
| 299 | if (packet->front_pointer - packet->buffer.s + LEN_FIELD_SIZE > |
| 300 | packet->buffer.len) |
| 301 | goto error; |
| 302 | |
| 303 | len = 0; |
| 304 | memcpy(&len, packet->front_pointer, LEN_FIELD_SIZE); |
| 305 | packet->front_pointer += LEN_FIELD_SIZE; |
| 306 | |
| 307 | if (packet->front_pointer - packet->buffer.s + len > packet->buffer.len) |
| 308 | goto error; |
| 309 | |
| 310 | packet->front_pointer += len; |
| 311 | } |
| 312 | |
| 313 | return 0; |
| 314 | |
| 315 | error: |
| 316 | LM_ERR("Receive binary packet buffer overflow\n"); |
| 317 | return -1; |
| 318 | } |
| 319 | |
| 320 | /* |
| 321 | * pops an str from the current position in the packet |
no outgoing calls
no test coverage detected