Lines Matching refs:len

30 sshbuf_get(struct sshbuf *buf, void *v, size_t len)  in sshbuf_get()  argument
35 if ((r = sshbuf_consume(buf, len)) < 0) in sshbuf_get()
37 if (v != NULL && len != 0) in sshbuf_get()
38 memcpy(v, p, len); in sshbuf_get()
98 size_t len; in sshbuf_get_string() local
105 if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0) in sshbuf_get_string()
108 if ((*valp = malloc(len + 1)) == NULL) { in sshbuf_get_string()
112 if (len != 0) in sshbuf_get_string()
113 memcpy(*valp, val, len); in sshbuf_get_string()
114 (*valp)[len] = '\0'; in sshbuf_get_string()
117 *lenp = len; in sshbuf_get_string()
124 size_t len; in sshbuf_get_string_direct() local
132 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) < 0) in sshbuf_get_string_direct()
137 *lenp = len; in sshbuf_get_string_direct()
138 if (sshbuf_consume(buf, len + 4) != 0) { in sshbuf_get_string_direct()
151 u_int32_t len; in sshbuf_peek_string_direct() local
162 len = PEEK_U32(p); in sshbuf_peek_string_direct()
163 if (len > SSHBUF_SIZE_MAX - 4) { in sshbuf_peek_string_direct()
167 if (sshbuf_len(buf) - 4 < len) { in sshbuf_peek_string_direct()
174 *lenp = len; in sshbuf_peek_string_direct()
181 size_t len; in sshbuf_get_cstring() local
189 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0) in sshbuf_get_cstring()
192 if (len > 0 && in sshbuf_get_cstring()
193 (z = memchr(p , '\0', len)) != NULL && z < p + len - 1) { in sshbuf_get_cstring()
200 if ((*valp = malloc(len + 1)) == NULL) { in sshbuf_get_cstring()
204 if (len != 0) in sshbuf_get_cstring()
205 memcpy(*valp, p, len); in sshbuf_get_cstring()
206 (*valp)[len] = '\0'; in sshbuf_get_cstring()
209 *lenp = (size_t)len; in sshbuf_get_cstring()
216 u_int32_t len; in sshbuf_get_stringb() local
226 (r = sshbuf_get_u32(buf, &len)) != 0 || in sshbuf_get_stringb()
227 (r = sshbuf_reserve(v, len, &p)) != 0 || in sshbuf_get_stringb()
228 (r = sshbuf_get(buf, p, len)) != 0) in sshbuf_get_stringb()
234 sshbuf_put(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put() argument
239 if ((r = sshbuf_reserve(buf, len, &p)) < 0) in sshbuf_put()
241 if (len != 0) in sshbuf_put()
242 memcpy(p, v, len); in sshbuf_put()
268 int r, len; in sshbuf_putfv() local
272 if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) { in sshbuf_putfv()
276 if (len == 0) { in sshbuf_putfv()
282 if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0) in sshbuf_putfv()
284 if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) { in sshbuf_putfv()
346 sshbuf_put_string(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put_string() argument
351 if (len > SSHBUF_SIZE_MAX - 4) { in sshbuf_put_string()
355 if ((r = sshbuf_reserve(buf, len + 4, &d)) < 0) in sshbuf_put_string()
357 POKE_U32(d, len); in sshbuf_put_string()
358 if (len != 0) in sshbuf_put_string()
359 memcpy(d + 4, v, len); in sshbuf_put_string()
379 size_t len; in sshbuf_froms() local
386 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0) in sshbuf_froms()
388 if ((ret = sshbuf_from(p, len)) == NULL) in sshbuf_froms()
390 if ((r = sshbuf_consume(buf, len + 4)) != 0 || /* Shouldn't happen */ in sshbuf_froms()
400 sshbuf_put_bignum2_bytes(struct sshbuf *buf, const void *v, size_t len) in sshbuf_put_bignum2_bytes() argument
406 if (len > SSHBUF_SIZE_MAX - 5) { in sshbuf_put_bignum2_bytes()
411 for (; len > 0 && *s == 0; len--, s++) in sshbuf_put_bignum2_bytes()
417 prepend = len > 0 && (s[0] & 0x80) != 0; in sshbuf_put_bignum2_bytes()
418 if ((r = sshbuf_reserve(buf, len + 4 + prepend, &d)) < 0) in sshbuf_put_bignum2_bytes()
420 POKE_U32(d, len + prepend); in sshbuf_put_bignum2_bytes()
423 if (len != 0) in sshbuf_put_bignum2_bytes()
424 memcpy(d + 4 + prepend, s, len); in sshbuf_put_bignum2_bytes()
433 size_t len, olen; in sshbuf_get_bignum2_bytes_direct() local
438 len = olen; in sshbuf_get_bignum2_bytes_direct()
440 if ((len != 0 && (*d & 0x80) != 0)) in sshbuf_get_bignum2_bytes_direct()
443 if (len > SSHBUF_MAX_BIGNUM + 1 || in sshbuf_get_bignum2_bytes_direct()
444 (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0)) in sshbuf_get_bignum2_bytes_direct()
447 while (len > 0 && *d == 0x00) { in sshbuf_get_bignum2_bytes_direct()
449 len--; in sshbuf_get_bignum2_bytes_direct()
454 *lenp = len; in sshbuf_get_bignum2_bytes_direct()