1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-03 13:47:25 +03:00

tdb: Add overflow-checking tdb_add_off_t

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Rusty Russell <rusty@rustcorp.com.au>
This commit is contained in:
Volker Lendecke 2013-05-30 14:52:59 +02:00
parent 42b0b27505
commit 4483bf143d
2 changed files with 12 additions and 0 deletions

View File

@ -1000,6 +1000,17 @@ bool tdb_write_all(int fd, const void *buf, size_t count)
return true;
}
bool tdb_add_off_t(tdb_off_t a, tdb_off_t b, tdb_off_t *pret)
{
tdb_off_t ret = a + b;
if ((ret < a) || (ret < b)) {
return false;
}
*pret = ret;
return true;
}
#ifdef TDB_TRACE
static void tdb_trace_write(struct tdb_context *tdb, const char *str)
{

View File

@ -282,4 +282,5 @@ void tdb_header_hash(struct tdb_context *tdb,
uint32_t *magic1_hash, uint32_t *magic2_hash);
unsigned int tdb_old_hash(TDB_DATA *key);
size_t tdb_dead_space(struct tdb_context *tdb, tdb_off_t off);
bool tdb_add_off_t(tdb_off_t a, tdb_off_t b, tdb_off_t *pret);
#endif /* TDB_PRIVATE_H */