diff options
Diffstat (limited to 'vxi11_server.c')
-rw-r--r-- | vxi11_server.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/vxi11_server.c b/vxi11_server.c index 186826d..3f1c9da 100644 --- a/vxi11_server.c +++ b/vxi11_server.c @@ -204,13 +204,18 @@ 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'; #ifdef DEBUG int n; char *str = argp->data.data_val; - for(n=0; str[n] != '\0'; n++) - printf("%02x ",(unsigned char)str[n]); + for (n = 0; str[n] != '\0'; n++) + printf("%02x ", (unsigned char) str[n]); printf("\n"); - printf("got <<%s>> on link %d.\n", argp->data.data_val, (int) argp->lid); + printf("got <<%s>> (reported length %d)on link %d.\n", argp->data.data_val, (int) argp->data.data_len, + (int) argp->lid); #endif Parser_main(argp->data.data_val, 0, GPIB_and_VXI_start_query_response, NULL); result.size = argp->data.data_len; |