diff options
author | daniel <danieruru@gmail.com> | 2013-01-26 13:10:08 +0900 |
---|---|---|
committer | daniel <danieruru@gmail.com> | 2013-01-26 13:10:08 +0900 |
commit | 35b28230e17a68db48f3b5fc91d2eec0c80e048c (patch) | |
tree | 3682265dbce6a376a9f65835d718515f448a4972 /libvxi11client/libvxi11client.c | |
parent | 67801485ab5a9e4509d2bb2cdd9454ee4ed1ab11 (diff) |
Add a "hack" to report back to the vxi11 service code when a link dies.
It's a hack because linux/glibc's RPC implementation doesn't seem to
have the ability to set a recv error callback. The hack is to add an
extra event to the events poll'd.. that event tells us if the socket
died.
Diffstat (limited to 'libvxi11client/libvxi11client.c')
-rw-r--r-- | libvxi11client/libvxi11client.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libvxi11client/libvxi11client.c b/libvxi11client/libvxi11client.c index 743168f..0e01809 100644 --- a/libvxi11client/libvxi11client.c +++ b/libvxi11client/libvxi11client.c @@ -214,8 +214,10 @@ int vxi11_read(VXI11Context* context, char* buffer, unsigned int bufferlen, bool #ifdef DEBUG printf("Got \"%s\" from server\n", resp->data.data_val); #endif - if (buffer != NULL) - strncpy(buffer, resp->data.data_val, (bufferlen < resp->data.data_len ? bufferlen : resp->data.data_len)); + if (buffer != NULL && resp->data.data_val != NULL) { + int lengthtocopy = ((bufferlen - 1) < resp->data.data_len ? (bufferlen - 1) : resp->data.data_len); + strncpy(buffer, resp->data.data_val, lengthtocopy); + } #ifdef DEBUG else printf("Supplied buffer is null!\n"); |