summaryrefslogtreecommitdiff
path: root/vxi11_server.c
diff options
context:
space:
mode:
Diffstat (limited to 'vxi11_server.c')
-rw-r--r--vxi11_server.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/vxi11_server.c b/vxi11_server.c
index 3f1c9da..cb7f600 100644
--- a/vxi11_server.c
+++ b/vxi11_server.c
@@ -204,10 +204,8 @@ device_write_1_svc(Device_WriteParms *argp, struct svc_req *rqstp) {
result.error = ERR_IOTIMEOUT;
else {
touchlink(argp->lid);
- // terminate the data at the length the client has given us..
- // this seems safe but I need check that this doesn't write
- // to memory that isn't allocated to the string.
- argp->data.data_val[argp->data.data_len] = '\0';
+ argp->data.data_val = realloc(argp->data.data_val, argp->data.data_len + 1); // realloc to get an extra byte
+ argp->data.data_val[argp->data.data_len] = '\0'; //
#ifdef DEBUG
int n;
char *str = argp->data.data_val;
@@ -247,7 +245,7 @@ device_read_1_svc(Device_ReadParms *argp, struct svc_req *rqstp) {
else {
touchlink(argp->lid);
if (globals.Registers.pending_output_message != NULL) {
- result.data.data_len = strlen(globals.Registers.pending_output_message) + 1;
+ result.data.data_len = strlen(globals.Registers.pending_output_message);
result.data.data_val = globals.Registers.pending_output_message;
globals.Registers.pending_output_message = NULL;
#ifdef DEBUG
@@ -440,6 +438,7 @@ device_enable_srq_1_svc(Device_EnableSrqParms *argp, struct svc_req *rqstp) {
Device_DocmdResp *
device_docmd_1_svc(Device_DocmdParms *argp, struct svc_req *rqstp) {
static Device_DocmdResp result;
+ memset(&result, 0, sizeof(result));
#ifdef DEBUG
printf("device_docmd_1_svc()\n");
#endif
@@ -449,8 +448,6 @@ device_docmd_1_svc(Device_DocmdParms *argp, struct svc_req *rqstp) {
result.error = ERR_DEVICELOCKEDBYANOTHERLINK;
else {
touchlink(argp->lid);
- result.data_out.data_out_len = 0;
- result.data_out.data_out_val = NULL;
result.error = ERR_OPERATIONNOTSUPPORTED;
}
return &result;