From 6a0ab0b2edca89da524b7dcf29994033f98c8552 Mon Sep 17 00:00:00 2001 From: Shehjar Tikoo Date: Wed, 3 Jun 2009 01:05:34 +0000 Subject: libglusterfs: Add empty and NULL dirents list checks These checks are needed in case a higher layer intends to delink the dirent list and passes a NULL pointer to fop_readdir_cbk_stub for the entries parameter. Consequently, the gf_dirent_free must guard against an empty list because the stub that is passed to it mgiht have an empty dirent list. Signed-off-by: Anand V. Avati --- libglusterfs/src/call-stub.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'libglusterfs/src/call-stub.c') diff --git a/libglusterfs/src/call-stub.c b/libglusterfs/src/call-stub.c index 63fe5be55..2447bf1ae 100644 --- a/libglusterfs/src/call-stub.c +++ b/libglusterfs/src/call-stub.c @@ -1992,6 +1992,12 @@ fop_readdir_cbk_stub (call_frame_t *frame, stub->args.readdir_cbk.op_errno = op_errno; INIT_LIST_HEAD (&stub->args.readdir_cbk.entries.list); + /* This check must come after the init of head above + * so we're sure the list is empty for list_empty. + */ + if (!entries) + goto out; + if (op_ret > 0) { list_for_each_entry (entry, &entries->list, list) { stub_entry = gf_dirent_for_name (entry->d_name); -- cgit