mirror of
https://github.com/openssh/libopenssh
synced 2026-04-17 02:06:45 +00:00
protect sshbuf_from[bs] children by refusing modification of the parent buffers
This adds a reference mechanism to struct sshbuf, making parent buffers to those created with buffer_froms() and buffer_fromb() read-only until the child buffer is freed. It also delays freeing of the parent buffer until all child buffers have freed.
This commit is contained in:
committed by
Markus Friedl
parent
fa6c75e284
commit
8f73555808
@@ -368,8 +368,9 @@ sshbuf_froms(struct sshbuf *buf, struct sshbuf **bufp)
|
||||
return r;
|
||||
if ((ret = sshbuf_from(p, len)) == NULL)
|
||||
return SSH_ERR_ALLOC_FAIL;
|
||||
if ((r = sshbuf_consume(buf, len + 4)) != 0) { /* Shouldn't happen */
|
||||
free(ret);
|
||||
if ((r = sshbuf_consume(buf, len + 4)) != 0 || /* Shouldn't happen */
|
||||
(r = sshbuf_set_parent(ret, buf)) != 0) {
|
||||
sshbuf_free(ret);
|
||||
return r;
|
||||
}
|
||||
*bufp = ret;
|
||||
|
||||
Reference in New Issue
Block a user