aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2020-10-08 15:01:30 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-10-08 15:01:30 +0100
commit929b9552f90bc399454f49ed993c796bf1f17863 (patch)
tree339320dac2c8251edc6c37c358846e8c68db0ac9
parent13cb850a6bbfa47b1768c5dc1b88ca91321bec20 (diff)
downloadpseudo-929b9552f90bc399454f49ed993c796bf1f17863.tar.gz
pseudo-929b9552f90bc399454f49ed993c796bf1f17863.tar.bz2
pseudo-929b9552f90bc399454f49ed993c796bf1f17863.zip
ports/linux/xattr: Fix NULL pointer dereference
In the xattr handling functions, if result is NULL, which it can be with the path ignore code, there is a NULL pointer dereference and segfault. Everywhere else checks result first, this appears to just be an omission. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--ports/linux/xattr/pseudo_wrappers.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/ports/linux/xattr/pseudo_wrappers.c b/ports/linux/xattr/pseudo_wrappers.c
index 3e122d9..0b65920 100644
--- a/ports/linux/xattr/pseudo_wrappers.c
+++ b/ports/linux/xattr/pseudo_wrappers.c
@@ -134,7 +134,7 @@ static ssize_t shared_getxattr(const char *path, int fd, const char *name, void
pseudo_debug(PDBGF_XATTR, "getxattr(%s [fd %d], %s)\n",
path ? path : "<no path>", fd, name);
pseudo_msg_t *result = pseudo_client_op(OP_GET_XATTR, 0, fd, -1, path, &buf, name);
- if (result->result != RESULT_SUCCEED) {
+ if (!result || result->result != RESULT_SUCCEED) {
errno = ENOATTR;
return -1;
}
@@ -254,7 +254,7 @@ static int shared_setxattr(const char *path, int fd, const char *name, const voi
static ssize_t shared_listxattr(const char *path, int fd, char *list, size_t size) {
RC_AND_BUF
pseudo_msg_t *result = pseudo_client_op(OP_LIST_XATTR, 0, fd, -1, path, &buf);
- if (result->result != RESULT_SUCCEED) {
+ if (!result || result->result != RESULT_SUCCEED) {
pseudo_debug(PDBGF_XATTR, "listxattr: no success.\n");
errno = ENOATTR;
return -1;
@@ -276,7 +276,7 @@ static int shared_removexattr(const char *path, int fd, const char *name) {
RC_AND_BUF
pseudo_msg_t *result = pseudo_client_op(OP_REMOVE_XATTR, 0, fd, -1, path, &buf, name);
- if (result->result != RESULT_SUCCEED) {
+ if (!result || result->result != RESULT_SUCCEED) {
/* docs say ENOATTR, but I don't have one */
errno = ENOENT;
return -1;