diff options
Diffstat (limited to 'winsup/cygwin/miscfuncs.cc')
-rw-r--r-- | winsup/cygwin/miscfuncs.cc | 70 |
1 files changed, 39 insertions, 31 deletions
diff --git a/winsup/cygwin/miscfuncs.cc b/winsup/cygwin/miscfuncs.cc index 741e6726b..eee47a53a 100644 --- a/winsup/cygwin/miscfuncs.cc +++ b/winsup/cygwin/miscfuncs.cc @@ -202,35 +202,38 @@ check_iovec (const struct iovec *iov, int iovcnt, bool forwrite) return -1; } - myfault efault; - if (efault.faulted (EFAULT)) - return -1; + __try + { - size_t tot = 0; + size_t tot = 0; - while (iovcnt != 0) - { - if (iov->iov_len > SSIZE_MAX || (tot += iov->iov_len) > SSIZE_MAX) + while (iovcnt != 0) { - set_errno (EINVAL); - return -1; - } + if (iov->iov_len > SSIZE_MAX || (tot += iov->iov_len) > SSIZE_MAX) + { + set_errno (EINVAL); + __leave; + } - volatile char *p = ((char *) iov->iov_base) + iov->iov_len - 1; - if (!iov->iov_len) - /* nothing to do */; - else if (!forwrite) - *p = dummytest (p); - else - dummytest (p); + volatile char *p = ((char *) iov->iov_base) + iov->iov_len - 1; + if (!iov->iov_len) + /* nothing to do */; + else if (!forwrite) + *p = dummytest (p); + else + dummytest (p); - iov++; - iovcnt--; - } + iov++; + iovcnt--; + } - assert (tot <= SSIZE_MAX); + assert (tot <= SSIZE_MAX); - return (ssize_t) tot; + return (ssize_t) tot; + } + __except (EFAULT) + __endtry + return -1; } /* Try hard to schedule another thread. @@ -512,18 +515,23 @@ slashify (const char *src, char *dst, bool trailing_slash_p) void * __reg1 __import_address (void *imp) { - myfault efault; - if (efault.faulted ()) - return NULL; - if (*((uint16_t *) imp) != 0x25ff) - return NULL; - const char *ptr = (const char *) imp; + __try + { + if (*((uint16_t *) imp) == 0x25ff) + { + const char *ptr = (const char *) imp; #ifdef __x86_64__ - const uintptr_t *jmpto = (uintptr_t *) (ptr + 6 + *(int32_t *)(ptr + 2)); + const uintptr_t *jmpto = (uintptr_t *) + (ptr + 6 + *(int32_t *)(ptr + 2)); #else - const uintptr_t *jmpto = (uintptr_t *) *((uintptr_t *) (ptr + 2)); + const uintptr_t *jmpto = (uintptr_t *) *((uintptr_t *) (ptr + 2)); #endif - return (void *) *jmpto; + return (void *) *jmpto; + } + } + __except (NO_ERROR) {} + __endtry + return NULL; } /* CygwinCreateThread. |