summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlan Coopersmith <alan.coopersmith@oracle.com>2013-05-05 00:32:45 -0700
committerAlan Coopersmith <alan.coopersmith@oracle.com>2013-05-05 18:25:17 -0700
commit740d0ab4aabe38331ff7b755a953aa0f1912c6f0 (patch)
tree89ec0e8754c1cfdeb04ef45f00501cf2df826aa4
parent60a1b6f5931538b15cdd485f50a268075a0ac81a (diff)
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 <alan.coopersmith@oracle.com>
-rw-r--r--src/server.c18
1 files 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;
}
}
}