Lines Matching refs:len

32 sshbuf_get(struct sshbuf *buf, void *v, size_t len)
37 if ((r = sshbuf_consume(buf, len)) < 0)
39 if (v != NULL && len != 0)
40 memcpy(v, p, len);
100 size_t len;
107 if ((r = sshbuf_get_string_direct(buf, &val, &len)) < 0)
110 if ((*valp = malloc(len + 1)) == NULL) {
114 if (len != 0)
115 memcpy(*valp, val, len);
116 (*valp)[len] = '\0';
119 *lenp = len;
126 size_t len;
134 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) < 0)
139 *lenp = len;
140 if (sshbuf_consume(buf, len + 4) != 0) {
153 u_int32_t len;
164 len = PEEK_U32(p);
165 if (len > SSHBUF_SIZE_MAX - 4) {
169 if (sshbuf_len(buf) - 4 < len) {
176 *lenp = len;
183 size_t len;
191 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
194 if (len > 0 &&
195 (z = memchr(p , '\0', len)) != NULL && z < p + len - 1) {
202 if ((*valp = malloc(len + 1)) == NULL) {
206 if (len != 0)
207 memcpy(*valp, p, len);
208 (*valp)[len] = '\0';
211 *lenp = (size_t)len;
218 u_int32_t len;
228 (r = sshbuf_get_u32(buf, &len)) != 0 ||
229 (r = sshbuf_reserve(v, len, &p)) != 0 ||
230 (r = sshbuf_get(buf, p, len)) != 0)
236 sshbuf_put(struct sshbuf *buf, const void *v, size_t len)
241 if ((r = sshbuf_reserve(buf, len, &p)) < 0)
243 if (len != 0)
244 memcpy(p, v, len);
270 int r, len;
274 if ((len = vsnprintf(NULL, 0, fmt, ap2)) < 0) {
278 if (len == 0) {
284 if ((r = sshbuf_reserve(buf, (size_t)len + 1, &p)) < 0)
286 if ((r = vsnprintf((char *)p, len + 1, fmt, ap2)) != len) {
348 sshbuf_put_string(struct sshbuf *buf, const void *v, size_t len)
353 if (len > SSHBUF_SIZE_MAX - 4) {
357 if ((r = sshbuf_reserve(buf, len + 4, &d)) < 0)
359 POKE_U32(d, len);
360 if (len != 0)
361 memcpy(d + 4, v, len);
381 size_t len;
388 if ((r = sshbuf_peek_string_direct(buf, &p, &len)) != 0)
390 if ((ret = sshbuf_from(p, len)) == NULL)
392 if ((r = sshbuf_consume(buf, len + 4)) != 0 || /* Shouldn't happen */
402 sshbuf_put_bignum2_bytes(struct sshbuf *buf, const void *v, size_t len)
408 if (len > SSHBUF_SIZE_MAX - 5) {
413 for (; len > 0 && *s == 0; len--, s++)
419 prepend = len > 0 && (s[0] & 0x80) != 0;
420 if ((r = sshbuf_reserve(buf, len + 4 + prepend, &d)) < 0)
422 POKE_U32(d, len + prepend);
425 if (len != 0)
426 memcpy(d + 4 + prepend, s, len);
435 size_t len, olen;
440 len = olen;
442 if ((len != 0 && (*d & 0x80) != 0))
445 if (len > SSHBUF_MAX_BIGNUM + 1 ||
446 (len == SSHBUF_MAX_BIGNUM + 1 && *d != 0))
449 while (len > 0 && *d == 0x00) {
451 len--;
456 *lenp = len;