From 740d0ab4aabe38331ff7b755a953aa0f1912c6f0 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Sun, 5 May 2013 00:32:45 -0700 Subject: Make query extension replies static, instead of pointers to stack buffers Make sure the data is still valid when its time to send to client Signed-off-by: Alan Coopersmith --- src/server.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/server.c b/src/server.c index d9e4c4d..e73eb08 100644 --- a/src/server.c +++ b/src/server.c @@ -531,7 +531,7 @@ HandleClientRequest(client_state *client, xhiv_response *responses) { int nbytes = client->req_len_remaining; char extension[32] = ""; - xQueryExtensionReply qext_reply = { + static const xQueryExtensionReply default_qext_reply = { .type = X_Reply, .length = 0, .present = xFalse, @@ -539,10 +539,18 @@ HandleClientRequest(client_state *client, xhiv_response *responses) .first_event = 0, .first_error = 0 }; + static const xQueryExtensionReply bigreq_qext_reply = { + .type = X_Reply, + .length = 0, + .present = xTrue, + .major_opcode = BIGREQ_REQTYPE, + .first_event = 0, + .first_error = 0 + }; xhiv_response default_qext_response = { .length = bytes_to_int32(sz_xQueryExtensionReply), - .response_data = &qext_reply, - .response_datalen = sizeof(qext_reply) + .response_data = &default_qext_reply, + .response_datalen = sizeof(default_qext_reply) }; xhiv_response *qext_response = &default_qext_response; @@ -567,8 +575,8 @@ HandleClientRequest(client_state *client, xhiv_response *responses) if (qext_response == &default_qext_response) { if (strncmp(extension + 4, XBigReqExtensionName, sizeof(XBigReqExtensionName)) == 0) { - qext_reply.present = xTrue; - qext_reply.major_opcode = BIGREQ_REQTYPE; + qext_response->response_data = + &bigreq_qext_reply; } } } -- cgit v1.2.3