Lines Matching refs:len
33 sshbuf_get(struct sshbuf *buf, void *v, size_t len) in sshbuf_get() argument
38 if ((r = sshbuf_consume(buf, len)) < 0) in sshbuf_get()
40 if (v != NULL && len != 0) in sshbuf_get()
41 memcpy(v, p, len); in sshbuf_get()
98 check_offset(const struct sshbuf *buf, int wr, size_t offset, size_t len) in check_offset() argument
102 if (offset >= SIZE_MAX - len) in check_offset()
104 if (offset + len > sshbuf_len(buf)) { in check_offset()
112 check_roffset(const struct sshbuf *buf, size_t offset, size_t len, in check_roffset() argument
118 if ((r = check_offset(buf, 0, offset, len)) != 0) in check_roffset()
188 size_t len; in sshbuf_get_string() local
195 if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0) in sshbuf_get_string()
198 if ((*valp = malloc(len + 1)) == NULL) { in sshbuf_get_string()
202 if (len != 0) in sshbuf_get_string()
203 memcpy(*valp, val, len); in sshbuf_get_string()
204 (*valp)[len] = '\0'; in sshbuf_get_string()
207 *lenp = len; in sshbuf_get_string()
214 size_t len; in sshbuf_get_string_direct() local
222 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) < 0) in sshbuf_get_string_direct()
227 *lenp = len; in sshbuf_get_string_direct()
228 if (sshbuf_consume(buf, len + 4) != 0) { in sshbuf_get_string_direct()
241 u_int32_t len; in sshbuf_peek_string_direct() local
252 len = PEEK_U32(p); in sshbuf_peek_string_direct()
253 if (len > SSHBUF_SIZE_MAX - 4) { in sshbuf_peek_string_direct()
257 if (sshbuf_len(buf) - 4 < len) { in sshbuf_peek_string_direct()
264 *lenp = len; in sshbuf_peek_string_direct()
271 size_t len; in sshbuf_get_cstring() local
279 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0) in sshbuf_get_cstring()
282 if (len > 0 && in sshbuf_get_cstring()
283 (z = memchr(p , '\0', len)) != NULL && z < p + len - 1) { in sshbuf_get_cstring()
290 if ((*valp = malloc(len + 1)) == NULL) { in sshbuf_get_cstring()
294 if (len != 0) in sshbuf_get_cstring()
295 memcpy(*valp, p, len); in sshbuf_get_cstring()
296 (*valp)[len] = '\0'; in sshbuf_get_cstring()
299 *lenp = (size_t)len; in sshbuf_get_cstring()
306 u_int32_t len; in sshbuf_get_stringb() local
316 (r = sshbuf_get_u32(buf, &len)) != 0 || in sshbuf_get_stringb()
317 (r = sshbuf_reserve(v, len, &p)) != 0 || in sshbuf_get_stringb()
318 (r = sshbuf_get(buf, p, len)) != 0) in sshbuf_get_stringb()
324 sshbuf_put(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put() argument
329 if ((r = sshbuf_reserve(buf, len, &p)) < 0) in sshbuf_put()
331 if (len != 0) in sshbuf_put()
332 memcpy(p, v, len); in sshbuf_put()
360 int r, len; in sshbuf_putfv() local
364 if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) { in sshbuf_putfv()
368 if (len == 0) { in sshbuf_putfv()
374 if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0) in sshbuf_putfv()
376 if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) { in sshbuf_putfv()
438 check_woffset(struct sshbuf *buf, size_t offset, size_t len, u_char **p) in check_woffset() argument
443 if ((r = check_offset(buf, 1, offset, len)) != 0) in check_woffset()
500 sshbuf_poke(struct sshbuf *buf, size_t offset, void *v, size_t len) in sshbuf_poke() argument
505 if ((r = check_woffset(buf, offset, len, &p)) != 0) in sshbuf_poke()
507 memcpy(p, v, len); in sshbuf_poke()
512 sshbuf_put_string(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put_string() argument
517 if (len > SSHBUF_SIZE_MAX - 4) { in sshbuf_put_string()
521 if ((r = sshbuf_reserve(buf, len + 4, &d)) < 0) in sshbuf_put_string()
523 POKE_U32(d, len); in sshbuf_put_string()
524 if (len != 0) in sshbuf_put_string()
525 memcpy(d + 4, v, len); in sshbuf_put_string()
548 size_t len; in sshbuf_froms() local
555 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0) in sshbuf_froms()
557 if ((ret = sshbuf_from(p, len)) == NULL) in sshbuf_froms()
559 if ((r = sshbuf_consume(buf, len + 4)) != 0 || /* Shouldn't happen */ in sshbuf_froms()
569 sshbuf_put_bignum2_bytes(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put_bignum2_bytes() argument
575 if (len > SSHBUF_SIZE_MAX - 5) { in sshbuf_put_bignum2_bytes()
580 for (; len > 0 && *s == 0; len--, s++) in sshbuf_put_bignum2_bytes()
586 prepend = len > 0 && (s[0] & 0x80) != 0; in sshbuf_put_bignum2_bytes()
587 if ((r = sshbuf_reserve(buf, len + 4 + prepend, &d)) < 0) in sshbuf_put_bignum2_bytes()
589 POKE_U32(d, len + prepend); in sshbuf_put_bignum2_bytes()
592 if (len != 0) in sshbuf_put_bignum2_bytes()
593 memcpy(d + 4 + prepend, s, len); in sshbuf_put_bignum2_bytes()
602 size_t len, olen; in sshbuf_get_bignum2_bytes_direct() local
607 len = olen; in sshbuf_get_bignum2_bytes_direct()
609 if ((len != 0 && (*d & 0x80) != 0)) in sshbuf_get_bignum2_bytes_direct()
612 if (len > SSHBUF_MAX_BIGNUM + 1 || in sshbuf_get_bignum2_bytes_direct()
613 (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0)) in sshbuf_get_bignum2_bytes_direct()
616 while (len > 0 && *d == 0x00) { in sshbuf_get_bignum2_bytes_direct()
618 len--; in sshbuf_get_bignum2_bytes_direct()
623 *lenp = len; in sshbuf_get_bignum2_bytes_direct()