Lines Matching refs:len

35 sshbuf_get(struct sshbuf *buf, void *v, size_t len)  in sshbuf_get()  argument
40 if ((r = sshbuf_consume(buf, len)) < 0) in sshbuf_get()
42 if (v != NULL && len != 0) in sshbuf_get()
43 memcpy(v, p, len); in sshbuf_get()
100 check_offset(const struct sshbuf *buf, int wr, size_t offset, size_t len) in check_offset() argument
104 if (offset >= SIZE_MAX - len) in check_offset()
106 if (offset + len > sshbuf_len(buf)) { in check_offset()
114 check_roffset(const struct sshbuf *buf, size_t offset, size_t len, in check_roffset() argument
120 if ((r = check_offset(buf, 0, offset, len)) != 0) in check_roffset()
190 size_t len; in sshbuf_get_string() local
197 if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0) in sshbuf_get_string()
200 if ((*valp = malloc(len + 1)) == NULL) { in sshbuf_get_string()
204 if (len != 0) in sshbuf_get_string()
205 memcpy(*valp, val, len); in sshbuf_get_string()
206 (*valp)[len] = '\0'; in sshbuf_get_string()
209 *lenp = len; in sshbuf_get_string()
216 size_t len; in sshbuf_get_string_direct() local
224 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) < 0) in sshbuf_get_string_direct()
229 *lenp = len; in sshbuf_get_string_direct()
230 if (sshbuf_consume(buf, len + 4) != 0) { in sshbuf_get_string_direct()
243 u_int32_t len; in sshbuf_peek_string_direct() local
254 len = PEEK_U32(p); in sshbuf_peek_string_direct()
255 if (len > SSHBUF_SIZE_MAX - 4) { in sshbuf_peek_string_direct()
259 if (sshbuf_len(buf) - 4 < len) { in sshbuf_peek_string_direct()
266 *lenp = len; in sshbuf_peek_string_direct()
273 size_t len; in sshbuf_get_cstring() local
281 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0) in sshbuf_get_cstring()
284 if (len > 0 && in sshbuf_get_cstring()
285 (z = memchr(p , '\0', len)) != NULL && z < p + len - 1) { in sshbuf_get_cstring()
292 if ((*valp = malloc(len + 1)) == NULL) { in sshbuf_get_cstring()
296 if (len != 0) in sshbuf_get_cstring()
297 memcpy(*valp, p, len); in sshbuf_get_cstring()
298 (*valp)[len] = '\0'; in sshbuf_get_cstring()
301 *lenp = (size_t)len; in sshbuf_get_cstring()
308 u_int32_t len; in sshbuf_get_stringb() local
318 (r = sshbuf_get_u32(buf, &len)) != 0 || in sshbuf_get_stringb()
319 (r = sshbuf_reserve(v, len, &p)) != 0 || in sshbuf_get_stringb()
320 (r = sshbuf_get(buf, p, len)) != 0) in sshbuf_get_stringb()
326 sshbuf_put(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put() argument
331 if ((r = sshbuf_reserve(buf, len, &p)) < 0) in sshbuf_put()
333 if (len != 0) in sshbuf_put()
334 memcpy(p, v, len); in sshbuf_put()
362 int r, len; in sshbuf_putfv() local
366 if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) { in sshbuf_putfv()
370 if (len == 0) { in sshbuf_putfv()
376 if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0) in sshbuf_putfv()
378 if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) { in sshbuf_putfv()
440 check_woffset(struct sshbuf *buf, size_t offset, size_t len, u_char **p) in check_woffset() argument
445 if ((r = check_offset(buf, 1, offset, len)) != 0) in check_woffset()
502 sshbuf_poke(struct sshbuf *buf, size_t offset, void *v, size_t len) in sshbuf_poke() argument
507 if ((r = check_woffset(buf, offset, len, &p)) != 0) in sshbuf_poke()
509 memcpy(p, v, len); in sshbuf_poke()
514 sshbuf_put_string(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put_string() argument
519 if (len > SSHBUF_SIZE_MAX - 4) { in sshbuf_put_string()
523 if ((r = sshbuf_reserve(buf, len + 4, &d)) < 0) in sshbuf_put_string()
525 POKE_U32(d, len); in sshbuf_put_string()
526 if (len != 0) in sshbuf_put_string()
527 memcpy(d + 4, v, len); in sshbuf_put_string()
550 size_t len; in sshbuf_froms() local
557 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0) in sshbuf_froms()
559 if ((ret = sshbuf_from(p, len)) == NULL) in sshbuf_froms()
561 if ((r = sshbuf_consume(buf, len + 4)) != 0 || /* Shouldn't happen */ in sshbuf_froms()
571 sshbuf_put_bignum2_bytes(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put_bignum2_bytes() argument
577 if (len > SSHBUF_SIZE_MAX - 5) { in sshbuf_put_bignum2_bytes()
582 for (; len > 0 && *s == 0; len--, s++) in sshbuf_put_bignum2_bytes()
588 prepend = len > 0 && (s[0] & 0x80) != 0; in sshbuf_put_bignum2_bytes()
589 if ((r = sshbuf_reserve(buf, len + 4 + prepend, &d)) < 0) in sshbuf_put_bignum2_bytes()
591 POKE_U32(d, len + prepend); in sshbuf_put_bignum2_bytes()
594 if (len != 0) in sshbuf_put_bignum2_bytes()
595 memcpy(d + 4 + prepend, s, len); in sshbuf_put_bignum2_bytes()
604 size_t len, olen; in sshbuf_get_bignum2_bytes_direct() local
609 len = olen; in sshbuf_get_bignum2_bytes_direct()
611 if ((len != 0 && (*d & 0x80) != 0)) in sshbuf_get_bignum2_bytes_direct()
614 if (len > SSHBUF_MAX_BIGNUM + 1 || in sshbuf_get_bignum2_bytes_direct()
615 (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0)) in sshbuf_get_bignum2_bytes_direct()
618 while (len > 0 && *d == 0x00) { in sshbuf_get_bignum2_bytes_direct()
620 len--; in sshbuf_get_bignum2_bytes_direct()
625 *lenp = len; in sshbuf_get_bignum2_bytes_direct()