From ac26e231394739abafd5f1f00722e44d6323de35 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 25 Jul 2001 18:59:56 +0000 Subject: Always check fstat for error. Jeremy. (This used to be commit 34951876a1bfad5aa3fc3bd05b808e150f639a8a) --- source3/tdb/tdb.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'source3/tdb/tdb.c') diff --git a/source3/tdb/tdb.c b/source3/tdb/tdb.c index c3ded6368b7..940825e41d8 100644 --- a/source3/tdb/tdb.c +++ b/source3/tdb/tdb.c @@ -127,14 +127,15 @@ struct list_struct { u32 full_hash; /* the full 32 bit hash of the key */ u32 magic; /* try to catch errors */ /* the following union is implied: - union { - char record[rec_len]; - struct { - char key[key_len]; - char data[data_len]; - } - u32 totalsize; (tailer) - } */ + union { + char record[rec_len]; + struct { + char key[key_len]; + char data[data_len]; + } + u32 totalsize; (tailer) + } + */ }; /* a byte range locking function - return 0 on success @@ -144,7 +145,7 @@ static int tdb_brlock(TDB_CONTEXT *tdb, tdb_off offset, { struct flock fl; - if (tdb->flags & TDB_NOLOCK) return 0; + if (tdb->flags & TDB_NOLOCK) return 0; if (tdb->read_only) return -1; fl.l_type = rw_type; @@ -234,7 +235,9 @@ static int tdb_oob(TDB_CONTEXT *tdb, tdb_off len, int probe) if (len <= tdb->map_size) return 0; if (tdb->flags & TDB_INTERNAL) return 0; - fstat(tdb->fd, &st); + if (fstat(tdb->fd, &st) == -1) + return TDB_ERRCODE(TDB_ERR_IO, -1); + if (st.st_size < (size_t)len) { if (!probe) { TDB_LOG((tdb, 0,"tdb_oob len %d beyond eof at %d\n", -- cgit v1.2.1