[Gluster-devel] Fwd: New Defects reported by Coverity Scan for GlusterFS

Lalatendu Mohanty lmohanty at redhat.com
Wed Apr 23 12:13:19 UTC 2014


Guideline for fixing Coverity issues :
http://www.gluster.org/community/documentation/index.php/Fixing_Issues_Reported_By_Tools_For_Static_Code_Analysis#Coverity

Thanks,
Lala
-------- Original Message --------
Subject: 	New Defects reported by Coverity Scan for GlusterFS
Date: 	Wed, 23 Apr 2014 04:33:37 -0700
From: 	scan-admin at coverity.com



Hi,


Please find the latest report on new defect(s) introduced to GlusterFS found with Coverity Scan.

Defect(s) Reported-by: Coverity Scan
Showing 4 of 4 defect(s)


** CID 1204962:  Function address comparison  (BAD_COMPARE)
/api/src/glfs-handleops.c: 394 in glfs_h_removexattrs()

** CID 1204961:  Function address comparison  (BAD_COMPARE)
/api/src/glfs-handleops.c: 338 in glfs_h_setxattrs()

** CID 1204963:  Dereference null return value  (NULL_RETURNS)
/rpc/rpc-lib/src/rpcsvc.c: 2519 in match_subnet_v4()

** CID 1204964:  Missing varargs init or cleanup  (VARARGS)
/libglusterfs/src/strfd.c: 47 in strprintf()
/libglusterfs/src/strfd.c: 54 in strprintf()
/libglusterfs/src/strfd.c: 66 in strprintf()
/libglusterfs/src/strfd.c: 79 in strprintf()


________________________________________________________________________________________________________
*** CID 1204962:  Function address comparison  (BAD_COMPARE)
/api/src/glfs-handleops.c: 394 in glfs_h_removexattrs()
388     	int              ret = -1;
389     	xlator_t        *subvol = NULL;
390     	inode_t         *inode = NULL;
391     	loc_t            loc = {0, };
392
393     	/* validate in args */
>>>     CID 1204962:  Function address comparison  (BAD_COMPARE)
>>>     This implicit conversion to a function pointer is suspicious: "stat(char const *, struct stat *) == NULL"; did you intend to call the function?
394     	if ((fs == NULL) || (object == NULL) || (stat == NULL)) {
395     		errno = EINVAL;
396     		return -1;
397     	}
398
399     	__glfs_entry_fs (fs);

________________________________________________________________________________________________________
*** CID 1204961:  Function address comparison  (BAD_COMPARE)
/api/src/glfs-handleops.c: 338 in glfs_h_setxattrs()
332     	xlator_t        *subvol = NULL;
333     	inode_t         *inode = NULL;
334     	loc_t            loc = {0, };
335     	dict_t          *xattr = NULL;
336
337     	/* validate in args */
>>>     CID 1204961:  Function address comparison  (BAD_COMPARE)
>>>     This implicit conversion to a function pointer is suspicious: "stat(char const *, struct stat *) == NULL"; did you intend to call the function?
338     	if ((fs == NULL) || (object == NULL) || (stat == NULL)) {
339     		errno = EINVAL;
340     		return -1;
341     	}
342
343     	__glfs_entry_fs (fs);

________________________________________________________________________________________________________
*** CID 1204963:  Dereference null return value  (NULL_RETURNS)
/rpc/rpc-lib/src/rpcsvc.c: 2519 in match_subnet_v4()
2513             /* Find the network socket addr of target */
2514             if (inet_pton (AF_INET, ipaddr, &sin1.sin_addr) == 0)
2515                     goto out;
2516
2517             /* Find the network socket addr of subnet pattern */
2518             slash = strchr (netaddr, '/');
>>>     CID 1204963:  Dereference null return value  (NULL_RETURNS)
>>>     Dereferencing a null pointer "slash".
2519             *slash = '\0';
2520             if (inet_pton (AF_INET, netaddr, &sin2.sin_addr) == 0)
2521                     goto out;
2522
2523             /*
2524              * Find the network mask in network byte order.

________________________________________________________________________________________________________
*** CID 1204964:  Missing varargs init or cleanup  (VARARGS)
/libglusterfs/src/strfd.c: 47 in strprintf()
41
42     	va_start (ap, fmt);
43
44     	size = vasprintf (&str, fmt, ap);
45
46     	if (size < 0)
>>>     CID 1204964:  Missing varargs init or cleanup  (VARARGS)
>>>     va_end was not called for "ap".
47     		return size;
48
49     	if (!strfd->alloc_size) {
50     		strfd->data = GF_CALLOC (max(size + 1, 4096), 1,
51     					 gf_common_mt_strfd_data_t);
52     		if (!strfd->data) {
/libglusterfs/src/strfd.c: 54 in strprintf()
48
49     	if (!strfd->alloc_size) {
50     		strfd->data = GF_CALLOC (max(size + 1, 4096), 1,
51     					 gf_common_mt_strfd_data_t);
52     		if (!strfd->data) {
53     			free (str); /* NOT GF_FREE */
>>>     CID 1204964:  Missing varargs init or cleanup  (VARARGS)
>>>     va_end was not called for "ap".
54     			return -1;
55     		}
56     		strfd->alloc_size = max(size + 1, 4096);
57     	}
58
59     	if (strfd->alloc_size <= (strfd->size + size)) {
/libglusterfs/src/strfd.c: 66 in strprintf()
60     		char *tmp_ptr = NULL;
61     		int new_size = max ((strfd->alloc_size * 2),
62     				    gf_roundup_next_power_of_two (strfd->size + size + 1));
63     		tmp_ptr = GF_REALLOC (strfd->data, new_size);
64     		if (!tmp_ptr) {
65     			free (str); /* NOT GF_FREE */
>>>     CID 1204964:  Missing varargs init or cleanup  (VARARGS)
>>>     va_end was not called for "ap".
66     			return -1;
67     		}
68     		strfd->alloc_size = new_size;
69     		strfd->data = tmp_ptr;
70     	}
71
/libglusterfs/src/strfd.c: 79 in strprintf()
73     	// This allows safe use of strfd->data as a string.
74     	memcpy (strfd->data + strfd->size, str, size + 1);
75     	strfd->size += size;
76
77     	free (str); /* NOT GF_FREE */
78
>>>     CID 1204964:  Missing varargs init or cleanup  (VARARGS)
>>>     va_end was not called for "ap".
79     	return size;
80     }
81
82
83     int
84     strfd_close (strfd_t *strfd)


________________________________________________________________________________________________________
To view the defects in Coverity Scan visit, http://scan.coverity.com/projects/987?tab=Overview

To unsubscribe from the email notification for new defects, http://scan5.coverity.com/cgi-bin/unsubscribe.py





-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://supercolony.gluster.org/pipermail/gluster-devel/attachments/20140423/511c3bd4/attachment-0001.html>


More information about the Gluster-devel mailing list