On 01/25/14 01:32 AM, walter harms wrote:


Am 25.01.2014 08:42, schrieb Alan Coopersmith:
Reported-by: Ilja Van Sprundel <[email protected]>
Signed-off-by: Alan Coopersmith <[email protected]>
---
  Xi/xichangehierarchy.c |    4 ++++
  1 file changed, 4 insertions(+)

diff --git a/Xi/xichangehierarchy.c b/Xi/xichangehierarchy.c
index e2f4b8a..9e36354 100644
--- a/Xi/xichangehierarchy.c
+++ b/Xi/xichangehierarchy.c
@@ -143,6 +143,10 @@ add_master(ClientPtr client, xXIAddMasterInfo * c, int 
flags[MAXDEVICES])
      int rc;

      name = calloc(c->name_len + 1, sizeof(char));
+    if (name == NULL) {
+        rc = BadAlloc;
+        goto unwind;
+    }
      strncpy(name, (char *) &c[1], c->name_len);

      rc = AllocDevicePair(client, name, &ptr, &keybd,


can you use strdup() here ?

I was thinking strndup() might work, but that would require checking the
later uses of the memory to ensure that they expect the allocated size to
be the string length, not exactly c->name_len + 1, if the two ever happen
to differ.   In any case, I left that as an exercise for someone else to
deal with.

--
        -Alan Coopersmith-              [email protected]
         Oracle Solaris Engineering - http://blogs.oracle.com/alanc
_______________________________________________
[email protected]: X.Org development
Archives: http://lists.x.org/archives/xorg-devel
Info: http://lists.x.org/mailman/listinfo/xorg-devel

Reply via email to