mirror of
https://github.com/gluster/glusterfs.git
synced 2026-02-06 00:49:30 +01:00
This commit address the wrong use of "size_t" instead of "ssize_t".
The functions that run xattr, like sys_lgetxattr(), sys_lgetxattr()
return negative values on error, that is, they return -1. But some of its users
were found capture this return in an unsigned "size_t" (implict type conversion).
This commit touches the posix xlator files posix-helpers.c and
posix-metadata.c, but also the tests get-mdata-xattr.c
In posix-helpers.c were found posix_cs_set_state, posix_cs_heal_state
and posix_cs_check_status the offending "size_t" in place of "ssize_t" for
the variable "xattrsize".
In posix-metadata.c was found posix_fetch_mdata_xattr and the
variable "size" using an unsigned "size_t" in the exact same way..
In get-mdata-xattr.c, the posix_fetch_mdata_xattr incurs in the
exact same offense with the variable "size".
This commit changes these cases to the signed "ssize_t".
Examples:
always true case
if (fd) {
xattrsize = sys_fgetxattr(*fd, GF_CS_OBJECT_REMOTE, NULL, 0);
if (xattrsize != -1) {
always false case
xattrsize = sys_fgetxattr(*fd, GF_CS_OBJECT_REMOTE, value,
xattrsize + 1);
if (xattrsize == -1) {
if (value)
GF_FREE(value);
Signed-off-by: Thales Antunes de Oliveira Barretto <thales.barretto.git@gmail.com>