diff options
author | daniel <danieruru@gmail.com> | 2013-01-25 15:24:58 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-25 15:24:58 +0900 |
commit | 8e631ffb02708f3f9492fa4031c65fee34c12174 (patch) | |
tree | 6657b473db01e783be8855f6129cd4e8fe72dda9 | |
parent | 937fcddf59817246db59f5be4af23c22e6c82cd5 (diff) |
force termination of the strings coming from the remote
-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; |