<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<br>
Guideline for fixing Coverity issues :<br>
<div class="moz-forward-container"><a class="moz-txt-link-freetext"
href="http://www.gluster.org/community/documentation/index.php/Fixing_Issues_Reported_By_Tools_For_Static_Code_Analysis#Coverity">http://www.gluster.org/community/documentation/index.php/Fixing_Issues_Reported_By_Tools_For_Static_Code_Analysis#Coverity</a><br>
<br>
Thanks,<br>
Lala<br>
-------- Original Message --------
<table class="moz-email-headers-table" border="0" cellpadding="0"
cellspacing="0">
<tbody>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Subject:
</th>
<td>New Defects reported by Coverity Scan for GlusterFS</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">Date: </th>
<td>Wed, 23 Apr 2014 04:33:37 -0700</td>
</tr>
<tr>
<th align="RIGHT" nowrap="nowrap" valign="BASELINE">From: </th>
<td><a class="moz-txt-link-abbreviated" href="mailto:scan-admin@coverity.com">scan-admin@coverity.com</a></td>
</tr>
</tbody>
</table>
<br>
<br>
<pre>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, <a class="moz-txt-link-freetext" href="http://scan.coverity.com/projects/987?tab=Overview">http://scan.coverity.com/projects/987?tab=Overview</a>
To unsubscribe from the email notification for new defects, <a class="moz-txt-link-freetext" href="http://scan5.coverity.com/cgi-bin/unsubscribe.py">http://scan5.coverity.com/cgi-bin/unsubscribe.py</a>
</pre>
<br>
</div>
<br>
</body>
</html>