diff options
author | Volker Lendecke <vl@samba.org> | 2013-05-30 14:52:59 +0200 |
---|---|---|
committer | Volker Lendecke <vl@samba.org> | 2013-06-03 10:21:20 +0200 |
commit | 4483bf143ddfee9ec07aed8f124559b00f757d9a (patch) | |
tree | 45f4a34ac35fefca010248428f30c0d1bfa27c75 /lib/tdb/common/tdb.c | |
parent | 42b0b275059f9c98b9bf417f2048fdc973449def (diff) | |
download | samba-4483bf143ddfee9ec07aed8f124559b00f757d9a.tar.gz samba-4483bf143ddfee9ec07aed8f124559b00f757d9a.tar.bz2 samba-4483bf143ddfee9ec07aed8f124559b00f757d9a.zip |
tdb: Add overflow-checking tdb_add_off_t
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'lib/tdb/common/tdb.c')
-rw-r--r-- | lib/tdb/common/tdb.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c index a2ae187f57..6256a05d04 100644 --- a/lib/tdb/common/tdb.c +++ b/lib/tdb/common/tdb.c @@ -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) { |