make sshbuf_get_stringb() a public API

This commit is contained in:
Markus Friedl
2012-02-21 02:51:09 +01:00
parent cbf6120318
commit f7ecade3a0
3 changed files with 25 additions and 26 deletions

View File

@@ -192,6 +192,26 @@ sshbuf_get_cstring(struct sshbuf *buf, char **valp, size_t *lenp)
return 0;
}
int
sshbuf_get_stringb(struct sshbuf *buf, struct sshbuf *v)
{
u_int32_t len;
u_char *p;
int r;
/*
* Use sshbuf_peek_string_direct() to figure out if there is
* a complete string in 'buf' and copy the string directly
* into 'v'.
*/
if ((r = sshbuf_peek_string_direct(buf, NULL, NULL)) != 0 ||
(r = sshbuf_get_u32(buf, &len)) != 0 ||
(r = sshbuf_reserve(v, len, &p)) != 0 ||
(r = sshbuf_get(buf, p, len)) != 0)
return r;
return 0;
}
int
sshbuf_put(struct sshbuf *buf, const void *v, size_t len)
{