--- a/libpisock/serial.c 2006-10-12 16:21:22.000000000 +0200 +++ b/libpisock/serial.c 2016-12-20 14:38:46.477854828 +0100 @@ -364,6 +364,7 @@ begin: if ((err = data->impl.open(ps, pa, addrlen)) < 0) { int save_errno = errno; + char* result = NULL; #ifdef MAXPATHLEN char realport[MAXPATHLEN]; #else @@ -374,8 +375,10 @@ # endif /* PATH_MAX */ #endif /* MAXPATHLEN */ - realpath(pa->pi_device, realport); + result = realpath(pa->pi_device, realport); errno = save_errno; + if (result == NULL) + result == realport; if (errno == ENOENT) { LOG((PI_DBG_DEV, PI_DBG_LVL_ERR, --- a/src/pilot-foto-treo600.c 2009-06-04 15:32:30.000000000 +0200 +++ b/src/pilot-foto-treo600.c 2016-12-20 15:24:35.897251325 +0100 @@ -86,8 +86,14 @@ } if (req_uid && uid == req_uid) { - memcpy(&req_uid, Pbuf, 4); /* get next req_uid for image 'block' */ - write(fd, Pbuf + 4, size - 4); /* The rest is just jpeg data */ + size_t done; + memcpy(&req_uid, Pbuf, 4); /* get next req_uid for image 'block' */ + done = write(fd, Pbuf + 4, size - 4); /* The rest is just jpeg data */ + if (done != size - 4) { + fprintf(stderr," ERROR: Error writing '%s' size %d\n\n", + imgfilename, size - 4); + return -1; + } } }