OSDN Git Service

mapi: Make private copies of name strings provided by client.
authorMario Kleiner <mario.kleiner.de@gmail.com>
Thu, 12 Mar 2015 22:34:12 +0000 (23:34 +0100)
committerEmil Velikov <emil.l.velikov@gmail.com>
Thu, 26 Mar 2015 01:47:11 +0000 (01:47 +0000)
commitd6413ed98fe07479d16cd2033d5379e06e5ce6d7
tree2de5583e27a9276d83671dcb1436af78f4802040
parent3147f0bd25c45c9bd2a2b1fec622eb1821e11df8
mapi: Make private copies of name strings provided by client.

glXGetProcAddress("glFoo") ends up in stub_add_dynamic() to
create dynamic stubs for dynamic functions. stub_add_dynamic()
doesn't store the caller provided name string "Foo" in a mesa
private copy, but just stores a pointer to the "glFoo" string
passed to glXGetProcAddress - a pointer into arbitrary memory
outside mesa's control.

If the caller passes some dynamically allocated/changing
memory buffer to glXGetProcAddress(), or the caller gets unmapped
from memory, e.g., some dynamically loaded application
plugin which uses OpenGL, this ends badly - with a dangling
pointer.

strdup() the name string provided by the client to avoid
this problem.

Cc: "10.3 10.4 10.5" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Mario Kleiner <mario.kleiner.de@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
(cherry picked from commit 1110113a7f0b6f9b21dd26dee8e95a021041c71c)
src/mapi/stub.c