diff options
Diffstat (limited to 'winsup/cygwin/libc')
-rw-r--r-- | winsup/cygwin/libc/arc4random.cc | 363 | ||||
-rw-r--r-- | winsup/cygwin/libc/base64.c | 316 | ||||
-rw-r--r-- | winsup/cygwin/libc/bsdlib.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/libc/fts.c | 18 | ||||
-rw-r--r-- | winsup/cygwin/libc/ftw.c | 4 | ||||
-rw-r--r-- | winsup/cygwin/libc/inet_network.c | 2 | ||||
-rw-r--r-- | winsup/cygwin/libc/minires-os-if.c | 9 | ||||
-rw-r--r-- | winsup/cygwin/libc/minires.c | 18 | ||||
-rw-r--r-- | winsup/cygwin/libc/nftw.c | 4 | ||||
-rw-r--r-- | winsup/cygwin/libc/rcmd.cc | 4 | ||||
-rw-r--r-- | winsup/cygwin/libc/rexec.cc | 2 |
11 files changed, 713 insertions, 31 deletions
diff --git a/winsup/cygwin/libc/arc4random.cc b/winsup/cygwin/libc/arc4random.cc new file mode 100644 index 000000000..2a38b1355 --- /dev/null +++ b/winsup/cygwin/libc/arc4random.cc @@ -0,0 +1,363 @@ +/* $OpenBSD: arc4random.c,v 1.22 2010/12/22 08:23:42 otto Exp $ */ + +/* + * Copyright (c) 1996, David Mazieres <dm@uun.org> + * Copyright (c) 2008, Damien Miller <djm@openbsd.org> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +/* + * Arc4 random number generator for OpenBSD. + * + * This code is derived from section 17.1 of Applied Cryptography, + * second edition, which describes a stream cipher allegedly + * compatible with RSA Labs "RC4" cipher (the actual description of + * which is a trade secret). The same algorithm is used as a stream + * cipher called "arcfour" in Tatu Ylonen's ssh package. + * + * RC4 is a registered trademark of RSA Laboratories. + */ + +#include <sys/cdefs.h> +__FBSDID("$FreeBSD: src/lib/libc/gen/arc4random.c,v 1.30 2012/11/17 01:49:23 svnexp Exp $"); + +#ifdef __CYGWIN__ +#include "winsup.h" +#include "sync.h" +#else +#include "namespace.h" +#endif +#include <fcntl.h> +#include <limits.h> +#include <stdlib.h> +#include <unistd.h> +#include <sys/types.h> +#include <sys/param.h> +#ifndef __CYGWIN__ +#include <sys/sysctl.h> +#endif +#include <sys/time.h> +#include <pthread.h> + +#ifndef __CYGWIN__ +#include "libc_private.h" +#include "un-namespace.h" +#endif + +#ifdef __CYGWIN__ +#define _open open +#define _read read +#define _close close +#endif + +#ifdef __GNUC__ +#define inline __inline +#else /* !__GNUC__ */ +#define inline +#endif /* !__GNUC__ */ + +struct arc4_stream { + u_int8_t i; + u_int8_t j; + u_int8_t s[256]; +}; + +#ifdef __CYGWIN__ +static NO_COPY muto arc4random_mtx; +#else +static pthread_mutex_t arc4random_mtx = PTHREAD_MUTEX_INITIALIZER; +#endif + +#define RANDOMDEV "/dev/random" +#define KEYSIZE 128 +#ifdef __CYGWIN__ +#define _ARC4_LOCK() \ + do { \ + if (__isthreaded) \ + arc4random_mtx.init ("arc4random_mtx")->acquire (); \ + } while (0) +#define _ARC4_UNLOCK() \ + do { \ + if (__isthreaded) \ + arc4random_mtx.release (); \ + } while (0) +#else +#define _ARC4_LOCK() \ + do { \ + if (__isthreaded) \ + _pthread_mutex_lock(&arc4random_mtx); \ + } while (0) + +#define _ARC4_UNLOCK() \ + do { \ + if (__isthreaded) \ + _pthread_mutex_unlock(&arc4random_mtx); \ + } while (0) +#endif + +static int rs_initialized; +static struct arc4_stream rs; +static pid_t arc4_stir_pid; +static int arc4_count; + +#ifndef __CYGWIN__ +extern int __sysctl(int *name, u_int namelen, void *oldp, size_t *oldlenp, + void *newp, size_t newlen); +#endif + +static inline u_int8_t arc4_getbyte(void); +static void arc4_stir(void); + +static inline void +arc4_init(void) +{ + int n; + + for (n = 0; n < 256; n++) + rs.s[n] = n; + rs.i = 0; + rs.j = 0; +} + +static inline void +arc4_addrandom(u_char *dat, int datlen) +{ + int n; + u_int8_t si; + + rs.i--; + for (n = 0; n < 256; n++) { + rs.i = (rs.i + 1); + si = rs.s[rs.i]; + rs.j = (rs.j + si + dat[n % datlen]); + rs.s[rs.i] = rs.s[rs.j]; + rs.s[rs.j] = si; + } + rs.j = rs.i; +} + +#ifndef __CYGWIN__ +static size_t +arc4_sysctl(u_char *buf, size_t size) +{ + int mib[2]; + size_t len, done; + + mib[0] = CTL_KERN; + mib[1] = KERN_ARND; + done = 0; + + do { + len = size; + if (__sysctl(mib, 2, buf, &len, NULL, 0) == -1) + return (done); + done += len; + buf += len; + size -= len; + } while (size > 0); + + return (done); +} +#endif + +static void +arc4_stir(void) +{ + int done, fd, i; + struct { + struct timeval tv; + pid_t pid; + u_char rnd[KEYSIZE]; + } rdat; + + if (!rs_initialized) { + arc4_init(); + rs_initialized = 1; + } + done = 0; +#ifndef __CYGWIN__ + if (arc4_sysctl((u_char *)&rdat, KEYSIZE) == KEYSIZE) + done = 1; +#endif + if (!done) { + fd = _open(RANDOMDEV, O_RDONLY | O_CLOEXEC, 0); + if (fd >= 0) { + if (_read(fd, &rdat, KEYSIZE) == KEYSIZE) + done = 1; + (void)_close(fd); + } + } + if (!done) { + (void)gettimeofday(&rdat.tv, NULL); + rdat.pid = getpid(); + /* We'll just take whatever was on the stack too... */ + } + + arc4_addrandom((u_char *)&rdat, KEYSIZE); + + /* + * Discard early keystream, as per recommendations in: + * "(Not So) Random Shuffles of RC4" by Ilya Mironov. + */ + for (i = 0; i < 1024; i++) + (void)arc4_getbyte(); + arc4_count = 1600000; +} + +static void +arc4_stir_if_needed(void) +{ + pid_t pid = getpid(); + + if (arc4_count <= 0 || !rs_initialized || arc4_stir_pid != pid) + { + arc4_stir_pid = pid; + arc4_stir(); + } +} + +static inline u_int8_t +arc4_getbyte(void) +{ + u_int8_t si, sj; + + rs.i = (rs.i + 1); + si = rs.s[rs.i]; + rs.j = (rs.j + si); + sj = rs.s[rs.j]; + rs.s[rs.i] = sj; + rs.s[rs.j] = si; + return (rs.s[(si + sj) & 0xff]); +} + +static inline u_int32_t +arc4_getword(void) +{ + u_int32_t val; + val = arc4_getbyte() << 24; + val |= arc4_getbyte() << 16; + val |= arc4_getbyte() << 8; + val |= arc4_getbyte(); + return val; +} + +void +arc4random_stir(void) +{ + _ARC4_LOCK(); + arc4_stir(); + _ARC4_UNLOCK(); +} + +void +arc4random_addrandom(u_char *dat, int datlen) +{ + _ARC4_LOCK(); + if (!rs_initialized) + arc4_stir(); + arc4_addrandom(dat, datlen); + _ARC4_UNLOCK(); +} + +u_int32_t +arc4random(void) +{ + u_int32_t val; + _ARC4_LOCK(); + arc4_count -= 4; + arc4_stir_if_needed(); + val = arc4_getword(); + _ARC4_UNLOCK(); + return val; +} + +void +arc4random_buf(void *_buf, size_t n) +{ + u_char *buf = (u_char *)_buf; + _ARC4_LOCK(); + arc4_stir_if_needed(); + while (n--) { + if (--arc4_count <= 0) + arc4_stir(); + buf[n] = arc4_getbyte(); + } + _ARC4_UNLOCK(); +} + +/* + * Calculate a uniformly distributed random number less than upper_bound + * avoiding "modulo bias". + * + * Uniformity is achieved by generating new random numbers until the one + * returned is outside the range [0, 2**32 % upper_bound). This + * guarantees the selected random number will be inside + * [2**32 % upper_bound, 2**32) which maps back to [0, upper_bound) + * after reduction modulo upper_bound. + */ +u_int32_t +arc4random_uniform(u_int32_t upper_bound) +{ + u_int32_t r, min; + + if (upper_bound < 2) + return 0; + +#if (ULONG_MAX > 0xffffffffUL) + min = 0x100000000UL % upper_bound; +#else + /* Calculate (2**32 % upper_bound) avoiding 64-bit math */ + if (upper_bound > 0x80000000) + min = 1 + ~upper_bound; /* 2**32 - upper_bound */ + else { + /* (2**32 - (x * 2)) % x == 2**32 % x when x <= 2**31 */ + min = ((0xffffffff - (upper_bound * 2)) + 1) % upper_bound; + } +#endif + + /* + * This could theoretically loop forever but each retry has + * p > 0.5 (worst case, usually far better) of selecting a + * number inside the range we need, so it should rarely need + * to re-roll. + */ + for (;;) { + r = arc4random(); + if (r >= min) + break; + } + + return r % upper_bound; +} + +#if 0 +/*-------- Test code for i386 --------*/ +#include <stdio.h> +#include <machine/pctr.h> +int +main(int argc, char **argv) +{ + const int iter = 1000000; + int i; + pctrval v; + + v = rdtsc(); + for (i = 0; i < iter; i++) + arc4random(); + v = rdtsc() - v; + v /= iter; + + printf("%qd cycles\n", v); +} +#endif diff --git a/winsup/cygwin/libc/base64.c b/winsup/cygwin/libc/base64.c new file mode 100644 index 000000000..933c92721 --- /dev/null +++ b/winsup/cygwin/libc/base64.c @@ -0,0 +1,316 @@ +/* + * Copyright (c) 1996, 1998 by Internet Software Consortium. + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS + * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES + * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE + * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL + * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR + * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS + * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS + * SOFTWARE. + */ + +/* + * Portions Copyright (c) 1995 by International Business Machines, Inc. + * + * International Business Machines, Inc. (hereinafter called IBM) grants + * permission under its copyrights to use, copy, modify, and distribute this + * Software with or without fee, provided that the above copyright notice and + * all paragraphs of this notice appear in all copies, and that the name of IBM + * not be used in connection with the marketing of any product incorporating + * the Software or modifications thereof, without specific, written prior + * permission. + * + * To the extent it has a right to do so, IBM grants an immunity from suit + * under its patents, if any, for the use, sale or manufacture of products to + * the extent that such products are used for performing Domain Name System + * dynamic updates in TCP/IP networks by means of the Software. No immunity is + * granted for any product per se or for any other function of any product. + * + * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, + * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING + * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN + * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. + */ + +#include <winsup.h> +#include <sys/cdefs.h> +__FBSDID("$FreeBSD: src/lib/libc/net/base64.c,v 1.6 2012/11/17 01:49:32 svnexp Exp $"); + +#include <sys/types.h> +#include <sys/param.h> +#include <sys/socket.h> + +#include <netinet/in.h> +#include <arpa/inet.h> +#include <arpa/nameser.h> + +#include <ctype.h> +#include <resolv.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +#define Assert(Cond) if (!(Cond)) abort() + +static const char Base64[] = + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; +static const char Pad64 = '='; + +/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) + The following encoding technique is taken from RFC 1521 by Borenstein + and Freed. It is reproduced here in a slightly edited form for + convenience. + + A 65-character subset of US-ASCII is used, enabling 6 bits to be + represented per printable character. (The extra 65th character, "=", + is used to signify a special processing function.) + + The encoding process represents 24-bit groups of input bits as output + strings of 4 encoded characters. Proceeding from left to right, a + 24-bit input group is formed by concatenating 3 8-bit input groups. + These 24 bits are then treated as 4 concatenated 6-bit groups, each + of which is translated into a single digit in the base64 alphabet. + + Each 6-bit group is used as an index into an array of 64 printable + characters. The character referenced by the index is placed in the + output string. + + Table 1: The Base64 Alphabet + + Value Encoding Value Encoding Value Encoding Value Encoding + 0 A 17 R 34 i 51 z + 1 B 18 S 35 j 52 0 + 2 C 19 T 36 k 53 1 + 3 D 20 U 37 l 54 2 + 4 E 21 V 38 m 55 3 + 5 F 22 W 39 n 56 4 + 6 G 23 X 40 o 57 5 + 7 H 24 Y 41 p 58 6 + 8 I 25 Z 42 q 59 7 + 9 J 26 a 43 r 60 8 + 10 K 27 b 44 s 61 9 + 11 L 28 c 45 t 62 + + 12 M 29 d 46 u 63 / + 13 N 30 e 47 v + 14 O 31 f 48 w (pad) = + 15 P 32 g 49 x + 16 Q 33 h 50 y + + Special processing is performed if fewer than 24 bits are available + at the end of the data being encoded. A full encoding quantum is + always completed at the end of a quantity. When fewer than 24 input + bits are available in an input group, zero bits are added (on the + right) to form an integral number of 6-bit groups. Padding at the + end of the data is performed using the '=' character. + + Since all base64 input is an integral number of octets, only the + ------------------------------------------------- + following cases can arise: + + (1) the final quantum of encoding input is an integral + multiple of 24 bits; here, the final unit of encoded + output will be an integral multiple of 4 characters + with no "=" padding, + (2) the final quantum of encoding input is exactly 8 bits; + here, the final unit of encoded output will be two + characters followed by two "=" padding characters, or + (3) the final quantum of encoding input is exactly 16 bits; + here, the final unit of encoded output will be three + characters followed by one "=" padding character. + */ + +int +b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) { + size_t datalength = 0; + u_char input[3]; + u_char output[4]; + size_t i; + + while (2 < srclength) { + input[0] = *src++; + input[1] = *src++; + input[2] = *src++; + srclength -= 3; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + output[3] = input[2] & 0x3f; + Assert(output[0] < 64); + Assert(output[1] < 64); + Assert(output[2] < 64); + Assert(output[3] < 64); + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + target[datalength++] = Base64[output[2]]; + target[datalength++] = Base64[output[3]]; + } + + /* Now we worry about padding. */ + if (0 != srclength) { + /* Get what's left. */ + input[0] = input[1] = input[2] = '\0'; + for (i = 0; i < srclength; i++) + input[i] = *src++; + + output[0] = input[0] >> 2; + output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4); + output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6); + Assert(output[0] < 64); + Assert(output[1] < 64); + Assert(output[2] < 64); + + if (datalength + 4 > targsize) + return (-1); + target[datalength++] = Base64[output[0]]; + target[datalength++] = Base64[output[1]]; + if (srclength == 1) + target[datalength++] = Pad64; + else + target[datalength++] = Base64[output[2]]; + target[datalength++] = Pad64; + } + if (datalength >= targsize) + return (-1); + target[datalength] = '\0'; /* Returned value doesn't count \0. */ + return (datalength); +} + +/* skips all whitespace anywhere. + converts characters, four at a time, starting at (or after) + src from base - 64 numbers into three 8 bit bytes in the target area. + it returns the number of data bytes stored at the target, or -1 on error. + */ + +int +b64_pton(src, target, targsize) + char const *src; + u_char *target; + size_t targsize; +{ + int tarindex, state, ch; + char *pos; + + state = 0; + tarindex = 0; + + while ((ch = *src++) != '\0') { + if (isspace((unsigned char)ch)) /* Skip whitespace anywhere. */ + continue; + + if (ch == Pad64) + break; + + pos = strchr(Base64, ch); + if (pos == 0) /* A non-base64 character. */ + return (-1); + + switch (state) { + case 0: + if (target) { + if ((size_t)tarindex >= targsize) + return (-1); + target[tarindex] = (pos - Base64) << 2; + } + state = 1; + break; + case 1: + if (target) { + if ((size_t)tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 4; + target[tarindex+1] = ((pos - Base64) & 0x0f) + << 4 ; + } + tarindex++; + state = 2; + break; + case 2: + if (target) { + if ((size_t)tarindex + 1 >= targsize) + return (-1); + target[tarindex] |= (pos - Base64) >> 2; + target[tarindex+1] = ((pos - Base64) & 0x03) + << 6; + } + tarindex++; + state = 3; + break; + case 3: + if (target) { + if ((size_t)tarindex >= targsize) + return (-1); + target[tarindex] |= (pos - Base64); + } + tarindex++; + state = 0; + break; + default: + abort(); + } + } + + /* + * We are done decoding Base-64 chars. Let's see if we ended + * on a byte boundary, and/or with erroneous trailing characters. + */ + + if (ch == Pad64) { /* We got a pad char. */ + ch = *src++; /* Skip it, get next. */ + switch (state) { + case 0: /* Invalid = in first position */ + case 1: /* Invalid = in second position */ + return (-1); + + case 2: /* Valid, means one byte of info */ + /* Skip any number of spaces. */ + for ((void)NULL; ch != '\0'; ch = *src++) + if (!isspace((unsigned char)ch)) + break; + /* Make sure there is another trailing = sign. */ + if (ch != Pad64) + return (-1); + ch = *src++; /* Skip the = */ + /* Fall through to "single trailing =" case. */ + /* FALLTHROUGH */ + + case 3: /* Valid, means two bytes of info */ + /* + * We know this char is an =. Is there anything but + * whitespace after it? + */ + for ((void)NULL; ch != '\0'; ch = *src++) + if (!isspace((unsigned char)ch)) + return (-1); + + /* + * Now make sure for cases 2 and 3 that the "extra" + * bits that slopped past the last full byte were + * zeros. If we don't check them, they become a + * subliminal channel. + */ + if (target && target[tarindex] != 0) + return (-1); + } + } else { + /* + * We ended by seeing the end of the string. Make sure we + * have no partial bytes lying around. + */ + if (state != 0) + return (-1); + } + + return (tarindex); +} diff --git a/winsup/cygwin/libc/bsdlib.cc b/winsup/cygwin/libc/bsdlib.cc index 599df7107..66cffc7d3 100644 --- a/winsup/cygwin/libc/bsdlib.cc +++ b/winsup/cygwin/libc/bsdlib.cc @@ -54,7 +54,7 @@ daemon (int nochdir, int noclose) break; default: /* This sleep avoids a race condition which kills the - child process if parent is started by a NT/W2K service. + child process if parent is started by a service process. FIXME: Is that still true? */ Sleep (1000L); _exit (0); @@ -112,7 +112,7 @@ openpty (int *amaster, int *aslave, char *name, const struct termios *termp, { grantpt (master); unlockpt (master); - __ptsname (pts, cygheap->fdtab[master]->get_unit ()); + __ptsname (pts, cygheap->fdtab[master]->get_minor ()); revoke (pts); if ((slave = open (pts, O_RDWR | O_NOCTTY)) >= 0) { diff --git a/winsup/cygwin/libc/fts.c b/winsup/cygwin/libc/fts.c index 7f292a57b..e82ec3fd7 100644 --- a/winsup/cygwin/libc/fts.c +++ b/winsup/cygwin/libc/fts.c @@ -94,7 +94,7 @@ static int fts_ufslinks(FTS *, const FTSENT *); struct _fts_private { FTS ftsp_fts; struct statfs ftsp_statfs; - __dev32_t ftsp_dev; + dev_t ftsp_dev; int ftsp_linksreliable; }; @@ -507,7 +507,7 @@ name: t = sp->fts_path + NAPPEND(p->fts_parent); /* ARGSUSED */ int fts_set(sp, p, instr) - FTS *sp; + FTS *sp __attribute__ ((unused)); FTSENT *p; int instr; { @@ -758,7 +758,7 @@ fts_build(sp, type) if ((p = fts_alloc(sp, dp->d_name, (int)dnamlen)) == NULL) goto mem1; - if (dnamlen >= maxlen) { /* include space for NUL */ + if ((int) dnamlen >= maxlen) { /* include space for NUL */ oldaddr = sp->fts_path; if (fts_palloc(sp, dnamlen + len + 1)) { /* @@ -907,9 +907,9 @@ fts_stat(sp, p, follow) int follow; { FTSENT *t; - __dev32_t dev; - __ino64_t ino; - struct __stat64 *sbp, sb; + dev_t dev; + ino_t ino; + struct stat *sbp, sb; int saved_errno; /* If user needs stat info, stat buffer already allocated. */ @@ -943,7 +943,7 @@ fts_stat(sp, p, follow) } } else if (lstat64(p->fts_accpath, sbp)) { p->fts_errno = errno; -err: memset(sbp, 0, sizeof(struct __stat64)); +err: memset(sbp, 0, sizeof(struct stat)); return (FTS_NS); } @@ -1041,7 +1041,7 @@ fts_alloc(sp, name, namelen) struct ftsent_withstat { FTSENT ent; - struct __stat64 statbuf; + struct stat statbuf; }; /* @@ -1177,7 +1177,7 @@ fts_safe_changedir(sp, p, fd, path) const char *path; { int ret, oerrno, newfd; - struct __stat64 sb; + struct stat sb; newfd = fd; if (ISSET(FTS_NOCHDIR)) diff --git a/winsup/cygwin/libc/ftw.c b/winsup/cygwin/libc/ftw.c index 9863e1621..61d1e7c21 100644 --- a/winsup/cygwin/libc/ftw.c +++ b/winsup/cygwin/libc/ftw.c @@ -41,8 +41,8 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/ftw.c,v 1.4 2004/08/24 13:0 #include <limits.h> int -ftw(const char *path, int (*fn)(const char *, const struct __stat64 *, int), - int nfds) +ftw(const char *path, int (*fn)(const char *, const struct stat *, int), + int nfds __attribute__ ((unused))) { char * const paths[2] = { (char *)path, NULL }; FTSENT *cur; diff --git a/winsup/cygwin/libc/inet_network.c b/winsup/cygwin/libc/inet_network.c index 01e1a7682..43a394cf4 100644 --- a/winsup/cygwin/libc/inet_network.c +++ b/winsup/cygwin/libc/inet_network.c @@ -62,7 +62,7 @@ cygwin_inet_network(cp) in_addr_t val, base, n; char c; in_addr_t parts[4], *pp = parts; - int i, digit; + unsigned int i, digit; again: val = 0; base = 10; digit = 0; diff --git a/winsup/cygwin/libc/minires-os-if.c b/winsup/cygwin/libc/minires-os-if.c index 46e8297fd..94460ffb2 100644 --- a/winsup/cygwin/libc/minires-os-if.c +++ b/winsup/cygwin/libc/minires-os-if.c @@ -37,7 +37,7 @@ details. */ ***********************************************************************/ #define PUTDOMAIN(d,p)\ - {int res = dn_comp(d, p, EndPtr - p, dnptrs, lastdnptr); p += res < 0 ? strlen(d) : res; } + {int res = dn_comp(d, p, EndPtr - p, dnptrs, lastdnptr); p += res < 0 ? (int) strlen(d) : res; } static u_char * write_record(unsigned char * ptr, PDNS_RECORD rr, unsigned char * EndPtr, unsigned char ** dnptrs, unsigned char ** lastdnptr, int debug) @@ -187,7 +187,8 @@ static int cygwin_query(res_state statp, const char * DomName, int Class, int Ty { DNS_STATUS res; PDNS_RECORD pQueryResultsSet, rr; - int section, len, counts[4] = {0, 0, 0, 0}, debug = statp->options & RES_DEBUG; + DWORD section; + int len, counts[4] = {0, 0, 0, 0}, debug = statp->options & RES_DEBUG; unsigned char * dnptrs[256], * ptr; dnptrs[0] = AnsPtr; @@ -309,7 +310,7 @@ static void get_registry_dns_items(PUNICODE_STRING in, res_state statp, size_t size = wcstombs (list, in->Buffer, in->Length); if (what == 0) { /* Get the addresses */ char *ap, *srch; - int numAddresses = 0; + size_t numAddresses = 0; for (ap = list; ap < list + size && *ap; ap = srch) { /* The separation character can be 0, ' ', or ','. */ for (srch = ap; *srch && (isdigit((unsigned) *srch) || *srch == '.' ); @@ -418,7 +419,7 @@ void get_dns_info(res_state statp) DWORD dwRetVal; IP_ADDR_STRING * pIPAddr; FIXED_INFO * pFixedInfo; - int numAddresses = 0; + size_t numAddresses = 0; if (statp->use_os) { diff --git a/winsup/cygwin/libc/minires.c b/winsup/cygwin/libc/minires.c index 0b3a7f3ac..c73ad3c58 100644 --- a/winsup/cygwin/libc/minires.c +++ b/winsup/cygwin/libc/minires.c @@ -177,9 +177,9 @@ static void get_resolv(res_state statp) if (!have_address && !strncasecmp("nameserver", words[0], sizes[0])) { for ( j = 1; j < i ; j++) { - unsigned int address; + in_addr_t address; address = cygwin_inet_addr(words[j]); - if (address == -1) { + if (address == INADDR_NONE) { DPRINTF(debug, "invalid server \"%s\"\n", words[j]); } else if (ns >= MAXNS) { @@ -295,7 +295,7 @@ int res_ninit(res_state statp) Mix the upper and lower bits as they are not used equally */ i = getpid(); statp->id = (ushort) (getppid() ^ (i << 8) ^ (i >> 8)); - for (i = 0; i < DIM(statp->dnsrch); i++) statp->dnsrch[i] = 0; + for (i = 0; i < (int) DIM(statp->dnsrch); i++) statp->dnsrch[i] = 0; /* resolv.conf (dns servers & search list)*/ get_resolv(statp); @@ -424,7 +424,7 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr, int MsgLength, unsigned char * AnsPtr, int AnsLength) { /* Current server, shared by all tasks */ - volatile static unsigned int SServ = 0XFFFFFFFF; + static volatile unsigned int SServ = 0XFFFFFFFF; int tcp; const int debug = statp->options & RES_DEBUG; @@ -459,7 +459,7 @@ int res_nsend( res_state statp, const unsigned char * MsgPtr, /* Close the socket if it had been opened before a fork. Reuse of pid's cannot hurt */ - if ((statp->sockfd != -1) && (statp->mypid != getpid())) { + if ((statp->sockfd != -1) && ((pid_t) statp->mypid != getpid())) { res_nclose(statp); } @@ -625,8 +625,10 @@ int res_send( const unsigned char * MsgPtr, int MsgLength, *****************************************************************/ int res_nmkquery (res_state statp, int op, const char * dnameptr, int qclass, int qtype, - const unsigned char * dataptr, int datalen, - const unsigned char * newrr, unsigned char * buf, int buflen) + const unsigned char * dataptr __attribute__ ((unused)), + int datalen __attribute__ ((unused)), + const unsigned char * newrr __attribute__ ((unused)), + unsigned char * buf, int buflen) { int i, len; const char * ptr; @@ -722,7 +724,7 @@ int res_nquerydomain( res_state statp, const char * Name, const char * DomName, int Class, int Type, unsigned char * AnsPtr, int AnsLength) { char fqdn[MAXDNAME], *ptr; - int nlen; + size_t nlen; if (!DomName) ptr = (char *) Name; diff --git a/winsup/cygwin/libc/nftw.c b/winsup/cygwin/libc/nftw.c index bb1c92381..1def24160 100644 --- a/winsup/cygwin/libc/nftw.c +++ b/winsup/cygwin/libc/nftw.c @@ -41,8 +41,8 @@ __FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/nftw.c,v 1.1.2.1 2004/08/29 #include <limits.h> int -nftw(const char *path, int (*fn)(const char *, const struct __stat64 *, int, - struct FTW *), int nfds, int ftwflags) +nftw(const char *path, int (*fn)(const char *, const struct stat *, int, + struct FTW *), int nfds __attribute__ ((unused)), int ftwflags) { char * const paths[2] = { (char *)path, NULL }; struct FTW ftw; diff --git a/winsup/cygwin/libc/rcmd.cc b/winsup/cygwin/libc/rcmd.cc index 16c05b01b..4ebdd062a 100644 --- a/winsup/cygwin/libc/rcmd.cc +++ b/winsup/cygwin/libc/rcmd.cc @@ -103,7 +103,7 @@ extern "C" { int cygwin_rresvport_af(int *alport, int family); int cygwin_select (int, fd_set *, fd_set *, fd_set *, struct timeval *); int cygwin_socket (int, int, int); - int seteuid32 (__uid32_t); + int seteuid32 (uid_t); } #endif @@ -421,7 +421,7 @@ iruserok_sa(const void *ra, int rlen, int superuser, const char *ruser, const char *luser) { const char *cp; - struct __stat64 sbuf; + struct stat sbuf; struct passwd *pwd; FILE *hostf; uid_t uid; diff --git a/winsup/cygwin/libc/rexec.cc b/winsup/cygwin/libc/rexec.cc index a09828675..d5548bf15 100644 --- a/winsup/cygwin/libc/rexec.cc +++ b/winsup/cygwin/libc/rexec.cc @@ -155,7 +155,7 @@ ruserpass(const char *host, char **aname, char **apass, char **aacct) char myname[INTERNET_MAX_HOST_NAME_LENGTH + 1]; const char *mydomain; int t, i, c, usedefault = 0; - struct __stat64 stb; + struct stat stb; hdir = getenv("HOME"); if (hdir == NULL) |