Add additional check to ensure wineserver doesn't crash if mem_alloc fails.

This commit is contained in:
Sebastian Lackner 2014-06-02 01:42:23 +02:00
parent 772dfd9f5a
commit fc086bb2bc

View File

@ -1,18 +1,18 @@
From f3596dd4a6dd481e67ff2c0e72aa5c4c74b1be72 Mon Sep 17 00:00:00 2001
From 8abcd1aac3f65585dfb2e761dd737c0609cd5f93 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Sun, 1 Jun 2014 23:46:09 +0200
Subject: server: Add additional checks in get_xattr_sd to prevent crashes
caused by invalid attributes.
---
server/file.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
server/file.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/server/file.c b/server/file.c
index 08231a7..d5d5ad4 100644
index 08231a7..11522c3 100644
--- a/server/file.c
+++ b/server/file.c
@@ -738,10 +738,16 @@ struct security_descriptor *get_xattr_sd( int fd )
@@ -738,12 +738,18 @@ struct security_descriptor *get_xattr_sd( int fd )
int n;
n = fgetxattr( fd, "user.wine.sd", buffer, sizeof(buffer) );
@ -28,8 +28,11 @@ index 08231a7..d5d5ad4 100644
+ return NULL;
+
sd = mem_alloc( n - 2 );
memcpy( sd, &buffer[2], n - 2 );
- memcpy( sd, &buffer[2], n - 2 );
+ if (sd) memcpy( sd, &buffer[2], n - 2 );
return sd;
#else
return NULL;
--
1.7.9.5