summaryrefslogtreecommitdiffstats
path: root/api
diff options
context:
space:
mode:
authorPurna Pavan Chandra Aekkaladevi <paekkala@redhat.com>2019-09-16 11:05:23 +0530
committerAmar Tumballi <amarts@gmail.com>2019-09-30 17:30:22 +0000
commit7464ece4b97935b8085ac456a452b697db3bf67e (patch)
tree7a34cf61706a8e0ddab55be67953e02e74cff5e7 /api
parentae729065c0d9cb5411e5c31231b5e293b560d76a (diff)
libgfapi : Dereference after null check - coverity fix
This patch fixes coverity issue with CID 1405581 A pointer 'volname' is being deferenced (by passing it as an argument to strncmp), even when it points to NULL, leading to segmentation fault. fix : Adding a NULL check condition beforehand and returning NULL Change-Id: I18685fa1cb251253996051b83b6790a5d5f0aff9 Updates: bz#789278 Signed-off-by: Purna Pavan Chandra Aekkaladevi <paekkala@redhat.com>
Diffstat (limited to 'api')
-rw-r--r--api/src/glfs.c7
1 files changed, 6 insertions, 1 deletions
diff --git a/api/src/glfs.c b/api/src/glfs.c
index 8226136..f83ecbc 100644
--- a/api/src/glfs.c
+++ b/api/src/glfs.c
@@ -816,6 +816,11 @@ unlock:
struct glfs *
pub_glfs_new(const char *volname)
{
+ if (!volname) {
+ errno = EINVAL;
+ return NULL;
+ }
+
struct glfs *fs = NULL;
int i = 0;
int ret = -1;
@@ -824,7 +829,7 @@ pub_glfs_new(const char *volname)
char pname[16] = "";
char msg[32] = "";
- if (!volname || volname[0] == '/' || volname[0] == '-') {
+ if (volname[0] == '/' || volname[0] == '-') {
if (strncmp(volname, "/snaps/", 7) == 0) {
goto label;
}