diff options
| author | Paul Eggert | 2011-04-14 13:16:48 -0700 |
|---|---|---|
| committer | Paul Eggert | 2011-04-14 13:16:48 -0700 |
| commit | 8bd7b8304a41da5dc0c8a11967c1a6005e9465d0 (patch) | |
| tree | 145588110166df723c31f3fceaa00c190b77aa8c /src/sysdep.c | |
| parent | cd64ea1d0df393beb93d1bdf19bd3990e3378f85 (diff) | |
| parent | 9024ff7943e9529ec38a80aaaa0db43224c1e885 (diff) | |
| download | emacs-8bd7b8304a41da5dc0c8a11967c1a6005e9465d0.tar.gz emacs-8bd7b8304a41da5dc0c8a11967c1a6005e9465d0.zip | |
Merge from mainline.
Diffstat (limited to 'src/sysdep.c')
| -rw-r--r-- | src/sysdep.c | 26 |
1 files changed, 19 insertions, 7 deletions
diff --git a/src/sysdep.c b/src/sysdep.c index 3dc255933ee..0d9b31f35cd 100644 --- a/src/sysdep.c +++ b/src/sysdep.c | |||
| @@ -1825,10 +1825,18 @@ emacs_close (int fd) | |||
| 1825 | return rtnval; | 1825 | return rtnval; |
| 1826 | } | 1826 | } |
| 1827 | 1827 | ||
| 1828 | int | 1828 | ssize_t |
| 1829 | emacs_read (int fildes, char *buf, unsigned int nbyte) | 1829 | emacs_read (int fildes, char *buf, size_t nbyte) |
| 1830 | { | 1830 | { |
| 1831 | register int rtnval; | 1831 | register ssize_t rtnval; |
| 1832 | |||
| 1833 | /* Defend against the possibility that a buggy caller passes a negative NBYTE | ||
| 1834 | argument, which would be converted to a large unsigned size_t NBYTE. This | ||
| 1835 | defense prevents callers from doing large writes, unfortunately. This | ||
| 1836 | size restriction can be removed once we have carefully checked that there | ||
| 1837 | are no such callers. */ | ||
| 1838 | if ((ssize_t) nbyte < 0) | ||
| 1839 | abort (); | ||
| 1832 | 1840 | ||
| 1833 | while ((rtnval = read (fildes, buf, nbyte)) == -1 | 1841 | while ((rtnval = read (fildes, buf, nbyte)) == -1 |
| 1834 | && (errno == EINTR)) | 1842 | && (errno == EINTR)) |
| @@ -1836,14 +1844,18 @@ emacs_read (int fildes, char *buf, unsigned int nbyte) | |||
| 1836 | return (rtnval); | 1844 | return (rtnval); |
| 1837 | } | 1845 | } |
| 1838 | 1846 | ||
| 1839 | int | 1847 | ssize_t |
| 1840 | emacs_write (int fildes, const char *buf, unsigned int nbyte) | 1848 | emacs_write (int fildes, const char *buf, size_t nbyte) |
| 1841 | { | 1849 | { |
| 1842 | register int rtnval, bytes_written; | 1850 | register ssize_t rtnval, bytes_written; |
| 1851 | |||
| 1852 | /* Defend against negative NBYTE, as in emacs_read. */ | ||
| 1853 | if ((ssize_t) nbyte < 0) | ||
| 1854 | abort (); | ||
| 1843 | 1855 | ||
| 1844 | bytes_written = 0; | 1856 | bytes_written = 0; |
| 1845 | 1857 | ||
| 1846 | while (nbyte > 0) | 1858 | while (nbyte != 0) |
| 1847 | { | 1859 | { |
| 1848 | rtnval = write (fildes, buf, nbyte); | 1860 | rtnval = write (fildes, buf, nbyte); |
| 1849 | 1861 | ||