From 64799b32a155daf8bfaa001fb6faf437134699b4 Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 26 Sep 2019 17:59:59 -0400 Subject: [PATCH] eio/dir: fix null deref Summary: above cases may fail, causing target to be null CID 1399103 Depends on D10210 Reviewers: cedric Reviewed By: cedric Subscribers: cedric, #reviewers, #committers Tags: #efl Differential Revision: https://phab.enlightenment.org/D10211 --- src/lib/eio/eio_dir.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/lib/eio/eio_dir.c b/src/lib/eio/eio_dir.c index 0ae68befde..076d337764 100644 --- a/src/lib/eio/eio_dir.c +++ b/src/lib/eio/eio_dir.c @@ -274,7 +274,7 @@ _eio_dir_link(Ecore_Thread *thread, Eio_Dir_Copy *order, /* recreate all links */ EINA_LIST_FOREACH(order->links, l, ln) { - ssize_t length; + ssize_t length = -1; eina_strbuf_reset(oldpath); @@ -299,7 +299,8 @@ _eio_dir_link(Ecore_Thread *thread, Eio_Dir_Copy *order, } /* read link target */ - length = readlink(ln, target, bsz); + if (target) + length = readlink(ln, target, bsz); if (length < 0) goto on_error;