From: Riccardo Magliocchetti Date: Fri, 1 Feb 2013 18:33:59 +0000 (+0100) Subject: afpd/fce_api: avoid null pointer dereference X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=netatalk.git;a=commitdiff_plain;h=71258bb5c7192740b80077c1131c1ffd5ba6ab4e afpd/fce_api: avoid null pointer dereference Move path NULL check before it is actually referenced. Reported by Coverity as CID #968570. --- diff --git a/etc/afpd/fce_api.c b/etc/afpd/fce_api.c index 49dd3cd7..36cce446 100644 --- a/etc/afpd/fce_api.c +++ b/etc/afpd/fce_api.c @@ -361,9 +361,10 @@ int fce_register(fce_ev_t event, const char *path, const char *oldpath, fce_obj_ return AFP_OK; AFP_ASSERT(event >= FCE_FIRST_EVENT && event <= FCE_LAST_EVENT); + AFP_ASSERT(path); LOG(log_debug, logtype_fce, "register_fce(path: %s, type: %s, event: %s", - path , type == fce_dir ? "dir" : "file", fce_event_names[event]); + path, type == fce_dir ? "dir" : "file", fce_event_names[event]); bname = basename_safe(path); @@ -371,8 +372,6 @@ int fce_register(fce_ev_t event, const char *path, const char *oldpath, fce_obj_ /* No listeners configured */ return AFP_OK; - if (path == NULL) - return AFPERR_PARAM; /* do some initialization on the fly the first time */ if (first_event) {