mirror of
https://github.com/gluster/glusterfs.git
synced 2026-02-05 15:48:40 +01:00
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>
This commit is contained in:
committed by
Amar Tumballi
parent
ae729065c0
commit
7464ece4b9
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user