Skip to content

Commit

Permalink
dbwrap: Adapt tdb_data_buf's overflow handling to modern conventions
Browse files Browse the repository at this point in the history
This is the way we do it right now, avoid confusion why "tmp" might be
needed

Signed-off-by: Volker Lendecke <[email protected]>
Reviewed-by: Jeremy Allison <[email protected]>
  • Loading branch information
vlendec authored and jrasamba committed May 8, 2019
1 parent 30abea8 commit 08a31c9
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions lib/dbwrap/dbwrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -634,14 +634,12 @@ static ssize_t tdb_data_buf(const TDB_DATA *dbufs, int num_dbufs,

for (i=0; i<num_dbufs; i++) {
size_t thislen = dbufs[i].dsize;
size_t tmp;

tmp = needed + thislen;
if (tmp < needed) {
needed += thislen;
if (needed < thislen) {
/* wrap */
return -1;
}
needed = tmp;

if ((thislen != 0) && (needed <= buflen)) {
memcpy(p, dbufs[i].dptr, thislen);
Expand Down

0 comments on commit 08a31c9

Please sign in to comment.