Skip to content

Commit

Permalink
ofpbuf: Fix arithmetic error in ofpbuf_insert().
Browse files Browse the repository at this point in the history
memmove byte count was calculated incorrectly as ofpbuf_put_uninit
is increasing b->size by n.

This patch fixes it by reducing byte count by n.

Reported-at: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=12296
Signed-off-by: Toms Atteka <cpp.code.lv@gmail.com>
Signed-off-by: Ben Pfaff <blp@ovn.org>
  • Loading branch information
TomCodeLV authored and blp committed Jan 18, 2019
1 parent b48aa14 commit 39976b9
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ofpbuf.c
Expand Up @@ -469,9 +469,9 @@ void
ofpbuf_insert(struct ofpbuf *b, size_t offset, const void *data, size_t n)
{
if (offset < b->size) {
ofpbuf_put_uninit(b, n);
ofpbuf_put_uninit(b, n); /* b->size gets increased. */
memmove((char *) b->data + offset + n, (char *) b->data + offset,
b->size - offset);
b->size - offset - n);
memcpy((char *) b->data + offset, data, n);
} else {
ovs_assert(offset == b->size);
Expand Down

0 comments on commit 39976b9

Please sign in to comment.