From 7d1de115db4c8b660d12ad1a72cb95ffa7f7a234 Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 8 Mar 1999 11:46:22 +0000 Subject: [PATCH] Update. 1999-03-08 Andreas Schwab * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Undo last change. /dev/pts status may change during runtime. 1999-03-08 Andreas Schwab * sysdeps/unix/sysv/linux/ttyname_r.c (__ttyname_r): Undo last change. /dev/pts status can change during runtime. 1999-03-07 Thorsten Kukuk * sunrpc/svc_tcp.c (readtcp): go into fatal error state if poll reports error. * nis/nss_nisplus/nisplus-parser.c: Avoid duplicate strlen calls, add some more sanity checks. * nis/nss_nisplus/nisplus-pwd.c: Include nisplus-parser.h for parser prototype. 1999-03-05 Thorsten Kukuk * sunrpc/rpc/xdr.h: Add x_getint32/x_putint32 to xdr_ops, change XDR_GETINT32/XDR_PUTINT32 to sue new functions. * sunrpc/xdr_mem.c: Add xdrmem_getint32, xdrmem_putint32. * sunrpc/xdr_rec.c: Add xdrrec_getint32, xdrrec_putint32. * sunrpc/xdr_sizeof.c: Add x_putint32, add dummy function for x_getint32. * sunrpc/xdr_stdio.c: Add xdrstdio_getint32, xdrstdio_putint32. * nis/nis_print.c: Fix ctime argument for platforms where sizeof (time_t) != sizeof (int). 255. Patch by Bruno Haible [PR libc/1010]. --- ChangeLog | 33 +++++++++++- FAQ | 48 ++++++++++-------- nis/nis_print.c | 10 ++-- nis/nss_nisplus/nisplus-parser.c | 78 ++++++++++++++++++++--------- nis/nss_nisplus/nisplus-pwd.c | 6 +-- sunrpc/rpc/xdr.h | 23 +++++---- sunrpc/svc_tcp.c | 5 +- sunrpc/xdr_mem.c | 38 +++++++++++++- sunrpc/xdr_rec.c | 60 +++++++++++++++++++--- sunrpc/xdr_sizeof.c | 10 ++++ sunrpc/xdr_stdio.c | 28 ++++++++++- sysdeps/unix/sysv/linux/ttyname.c | 22 ++++---- sysdeps/unix/sysv/linux/ttyname_r.c | 25 ++++----- 13 files changed, 284 insertions(+), 102 deletions(-) diff --git a/ChangeLog b/ChangeLog index 421f4c0300..6e769be459 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,34 @@ +1999-03-08 Andreas Schwab + + * sysdeps/unix/sysv/linux/ttyname.c (ttyname): Undo last change. + /dev/pts status may change during runtime. + +1999-03-08 Andreas Schwab + + * sysdeps/unix/sysv/linux/ttyname_r.c (__ttyname_r): Undo last + change. /dev/pts status can change during runtime. + +1999-03-07 Thorsten Kukuk + + * sunrpc/svc_tcp.c (readtcp): go into fatal error state if + poll reports error. + * nis/nss_nisplus/nisplus-parser.c: Avoid duplicate strlen calls, + add some more sanity checks. + * nis/nss_nisplus/nisplus-pwd.c: Include nisplus-parser.h for + parser prototype. + +1999-03-05 Thorsten Kukuk + + * sunrpc/rpc/xdr.h: Add x_getint32/x_putint32 to xdr_ops, + change XDR_GETINT32/XDR_PUTINT32 to sue new functions. + * sunrpc/xdr_mem.c: Add xdrmem_getint32, xdrmem_putint32. + * sunrpc/xdr_rec.c: Add xdrrec_getint32, xdrrec_putint32. + * sunrpc/xdr_sizeof.c: Add x_putint32, add dummy function + for x_getint32. + * sunrpc/xdr_stdio.c: Add xdrstdio_getint32, xdrstdio_putint32. + * nis/nis_print.c: Fix ctime argument for platforms where + sizeof (time_t) != sizeof (int). + 1999-03-07 Mark Kettenis * sysdeps/unix/bsd/clock.c (timeval_to_clock_t): Use @@ -16,7 +47,7 @@ 1999-03-05 Andreas Jaeger * resolv/inet_addr.c (inet_aton): Don't allow componets > - 255. Patch by Bruno Haible [PR libc/1010]. + 255. Patch by Bruno Haible [PR libc/1010]. 1999-03-05 Geoff Keating diff --git a/FAQ b/FAQ index 7c3dd1d424..3de7dfec50 100644 --- a/FAQ +++ b/FAQ @@ -141,24 +141,23 @@ please let me know. 3.18. After upgrading to glibc 2.1, I receive errors about unresolved symbols, like `_dl_initial_searchlist' and can not execute any binaries. What went wrong? +3.19. bonnie reports that char i/o with glibc 2 is much slower than with + libc5. What can be done? -4. bonnie reports that char i/o with glibc 2 is much slower than with +4. Miscellaneous - -5. Miscellaneous - -5.1. After I changed configure.in I get `Autoconf version X.Y. +4.1. After I changed configure.in I get `Autoconf version X.Y. or higher is required for this script'. What can I do? -5.2. When I try to compile code which uses IPv6 headers and +4.2. When I try to compile code which uses IPv6 headers and definitions on my Linux 2.x.y system I am in trouble. Nothing seems to work. -5.3. When I set the timezone by setting the TZ environment variable +4.3. When I set the timezone by setting the TZ environment variable to EST5EDT things go wrong since glibc computes the wrong time from this information. -5.4. What other sources of documentation about glibc are available? -5.5. The timezone string for Sydney/Australia is wrong since even when +4.4. What other sources of documentation about glibc are available? +4.5. The timezone string for Sydney/Australia is wrong since even when daylight saving time is in effect the timezone string is EST. -5.6. I've build make 3.77 against glibc 2.1 and now make gets +4.6. I've build make 3.77 against glibc 2.1 and now make gets segmentation faults. @@ -228,7 +227,7 @@ We recommend version GNU make version 3.75 or 3.77. Versions before 3.75 have bugs and/or are missing features. Version 3.76 has bugs which appear when building big projects like GNU libc. 3.76.1 appears to work but some people have reported problems. If you build GNU make 3.77 from source, -please read question 5.6 first. +please read question 4.6 first. 1.4. Do I need a special linker or assembler? @@ -1194,7 +1193,7 @@ defined). Instead GNU libc contains zone database support and compatibility code for POSIX TZ environment variable handling. For former is very much preferred -(see question 5.3). +(see question 4.3). 3.4. The prototypes for `connect', `accept', `getsockopt', @@ -1488,24 +1487,29 @@ When compiling new programs against glibc 2.1, you've got to specify the correct paths to the compiler (option -I with gcc) and linker (options --dynamic-linker, -L and --rpath). - -. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -4. bonnie reports that char i/o with glibc 2 is much slower than with +3.19. bonnie reports that char i/o with glibc 2 is much slower than with + libc5. What can be done? + +{AJ} The GNU C library uses thread safe functions by default and libc5 used +non thread safe versions. The non thread safe functions have in glibc the +suffix `_unlocked', for details check . Using `putc_unlocked' etc. +instead of `putc' should give nearly the same speed with bonnie (bonnie is a +benchmark program for measuring disk access). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . -5. Miscellaneous +4. Miscellaneous -5.1. After I changed configure.in I get `Autoconf version X.Y. +4.1. After I changed configure.in I get `Autoconf version X.Y. or higher is required for this script'. What can I do? {UD} You have to get the specified autoconf version (or a later one) from your favorite mirror of ftp.gnu.org. -5.2. When I try to compile code which uses IPv6 headers and +4.2. When I try to compile code which uses IPv6 headers and definitions on my Linux 2.x.y system I am in trouble. Nothing seems to work. @@ -1529,7 +1533,7 @@ Also, as of the 2.1 release the IPv6 API provided by GNU libc is not functions are not implemented. -5.3. When I set the timezone by setting the TZ environment variable +4.3. When I set the timezone by setting the TZ environment variable to EST5EDT things go wrong since glibc computes the wrong time from this information. @@ -1554,7 +1558,7 @@ the POSIX method and you have not verified something is really broken by reading the POSIX standards. -5.4. What other sources of documentation about glibc are available? +4.4. What other sources of documentation about glibc are available? {AJ} The FSF has a page about the GNU C library at . The problem data base of open and @@ -1568,7 +1572,7 @@ Looijaard describes a different way installing glibc2 as secondary libc at Please note that this is not a complete list. -5.5. The timezone string for Sydney/Australia is wrong since even when +4.5. The timezone string for Sydney/Australia is wrong since even when daylight saving time is in effect the timezone string is EST. {UD} The problem for some timezones is that the local authorities decided @@ -1583,7 +1587,7 @@ Great! To get this bug fixed convince the authorities to change the laws and regulations of the country this effects. glibc behaves correctly. -5.6. I've build make 3.77 against glibc 2.1 and now make gets +4.6. I've build make 3.77 against glibc 2.1 and now make gets segmentation faults. {AJ} GNU make 3.77 has support for 64 bit filesystems which is slightly diff --git a/nis/nis_print.c b/nis/nis_print.c index 4ad51b23ea..ded5f5aa67 100644 --- a/nis/nis_print.c +++ b/nis/nis_print.c @@ -1,4 +1,4 @@ -/* Copyright (c) 1997, 1998 Free Software Foundation, Inc. +/* Copyright (c) 1997, 1998, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -311,6 +311,8 @@ nis_print_entry (const entry_obj *obj) void nis_print_object (const nis_object * obj) { + time_t buf; + printf (_("Object Name : %s\n"), obj->zo_name); printf (_("Directory : %s\n"), obj->zo_domain); printf (_("Owner : %s\n"), obj->zo_owner); @@ -319,8 +321,10 @@ nis_print_object (const nis_object * obj) nis_print_rights (obj->zo_access); printf (_("\nTime to Live : ")); print_ttl (obj->zo_ttl); - printf (_("Creation Time : %s"), ctime ((time_t *)&obj->zo_oid.ctime)); - printf (_("Mod. Time : %s"), ctime ((time_t *)&obj->zo_oid.mtime)); + buf = obj->zo_oid.ctime; + printf (_("Creation Time : %s"), ctime (&buf)); + buf = obj->zo_oid.mtime; + printf (_("Mod. Time : %s"), ctime (&buf)); fputs (_("Object Type : "), stdout); nis_print_objtype (obj->zo_data.zo_type); switch (obj->zo_data.zo_type) diff --git a/nis/nss_nisplus/nisplus-parser.c b/nis/nss_nisplus/nisplus-parser.c index fa4073e6d8..35b8a2881e 100644 --- a/nis/nss_nisplus/nisplus-parser.c +++ b/nis/nss_nisplus/nisplus-parser.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -38,6 +38,7 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, { char *first_unused = buffer; size_t room_left = buflen; + size_t len; if (result == NULL) return 0; @@ -61,9 +62,12 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, strncpy (first_unused, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); first_unused[NISENTRYLEN (0, 0, result)] = '\0'; + len = strlen (first_unused); + if (len == 0) /* No name ? Should never happen, database is corrupt */ + return 0; pw->pw_name = first_unused; - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN (0, 1, result) >= room_left) goto no_more_room; @@ -72,8 +76,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, NISENTRYLEN (0, 1, result)); first_unused[NISENTRYLEN (0, 1, result)] = '\0'; pw->pw_passwd = first_unused; - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + len = strlen (first_unused); + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN(0, 2, result) >= room_left) goto no_more_room; @@ -81,9 +86,12 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, strncpy (first_unused, NISENTRYVAL (0, 2, result), NISENTRYLEN (0, 2, result)); first_unused[NISENTRYLEN (0, 2, result)] = '\0'; + len = strlen (first_unused); + if (len == 0) /* If we don't have a uid, it's an invalid shadow entry */ + return 0; pw->pw_uid = atoi (first_unused); - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN (0, 3, result) >= room_left) goto no_more_room; @@ -91,9 +99,12 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, strncpy (first_unused, NISENTRYVAL (0, 3, result), NISENTRYLEN (0, 3, result)); first_unused[NISENTRYLEN (0, 3, result)] = '\0'; + len = strlen (first_unused); + if (len == 0) /* If we don't have a gid, it's an invalid shadow entry */ + return 0; pw->pw_gid = atoi (first_unused); - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN(0, 4, result) >= room_left) goto no_more_room; @@ -102,8 +113,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, NISENTRYLEN (0, 4, result)); first_unused[NISENTRYLEN (0, 4, result)] = '\0'; pw->pw_gecos = first_unused; - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + len = strlen (first_unused); + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN (0, 5, result) >= room_left) goto no_more_room; @@ -112,8 +124,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, NISENTRYLEN (0, 5, result)); first_unused[NISENTRYLEN (0, 5, result)] = '\0'; pw->pw_dir = first_unused; - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + len = strlen (first_unused); + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN (0, 6, result) >= room_left) goto no_more_room; @@ -122,8 +135,9 @@ _nss_nisplus_parse_pwent (nis_result *result, struct passwd *pw, NISENTRYLEN (0, 6, result)); first_unused[NISENTRYLEN (0, 6, result)] = '\0'; pw->pw_shell = first_unused; - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + len = strlen (first_unused); + room_left -= (len + 1); + first_unused += (len + 1); return 1; } @@ -136,6 +150,7 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr, size_t room_left = buflen; char *line; int count; + size_t len; if (result == NULL) return 0; @@ -158,9 +173,12 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr, strncpy (first_unused, NISENTRYVAL (entry, 0, result), NISENTRYLEN (entry, 0, result)); first_unused[NISENTRYLEN (entry, 0, result)] = '\0'; + len = strlen (first_unused); + if (len == 0) /* group table is corrupt */ + return 0; gr->gr_name = first_unused; - room_left -= (strlen (first_unused) + 1); - first_unused += strlen (first_unused) + 1; + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN (entry, 1, result) >= room_left) goto no_more_room; @@ -169,8 +187,9 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr, NISENTRYLEN (entry, 1, result)); first_unused[NISENTRYLEN (entry, 1, result)] = '\0'; gr->gr_passwd = first_unused; - room_left -= (strlen (first_unused) + 1); - first_unused += strlen (first_unused) + 1; + len = strlen (first_unused); + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN (entry, 2, result) >= room_left) goto no_more_room; @@ -178,6 +197,9 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr, strncpy (first_unused, NISENTRYVAL (entry, 2, result), NISENTRYLEN (entry, 2, result)); first_unused[NISENTRYLEN (entry, 2, result)] = '\0'; + len = strlen (first_unused); + if (len == 0) /* We should always have an gid */ + return 0; gr->gr_gid = atoi (first_unused); room_left -= (strlen (first_unused) + 1); first_unused += strlen (first_unused) + 1; @@ -189,8 +211,9 @@ _nss_nisplus_parse_grent (nis_result *result, u_long entry, struct group *gr, NISENTRYLEN (entry, 3, result)); first_unused[NISENTRYLEN (entry, 3, result)] = '\0'; line = first_unused; - room_left -= (strlen (line) + 1); - first_unused += strlen (line) + 1; + len = strlen (line); + room_left -= (len + 1); + first_unused += (len + 1); /* Adjust the pointer so it is aligned for storing pointers. */ first_unused += __alignof__ (char *) - 1; @@ -244,6 +267,7 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, { char *first_unused = buffer; size_t room_left = buflen; + size_t len; if (result == NULL) return 0; @@ -267,9 +291,12 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, strncpy (first_unused, NISENTRYVAL (0, 0, result), NISENTRYLEN (0, 0, result)); first_unused[NISENTRYLEN (0, 0, result)] = '\0'; + len = strlen (first_unused); + if (len == 0) + return 0; sp->sp_namp = first_unused; - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + room_left -= (len + 1); + first_unused += (len + 1); if (NISENTRYLEN (0, 1, result) >= room_left) goto no_more_room; @@ -278,8 +305,9 @@ _nss_nisplus_parse_spent (nis_result *result, struct spwd *sp, NISENTRYLEN (0, 1, result)); first_unused[NISENTRYLEN (0, 1, result)] = '\0'; sp->sp_pwdp = first_unused; - room_left -= (strlen (first_unused) +1); - first_unused += strlen (first_unused) +1; + len = strlen (first_unused); + room_left -= (len + 1); + first_unused += (len + 1); sp->sp_lstchg = sp->sp_min = sp->sp_max = sp->sp_warn = sp->sp_inact = sp->sp_expire = sp->sp_flag = -1; diff --git a/nis/nss_nisplus/nisplus-pwd.c b/nis/nss_nisplus/nisplus-pwd.c index 45c364ac39..194b97ff65 100644 --- a/nis/nss_nisplus/nisplus-pwd.c +++ b/nis/nss_nisplus/nisplus-pwd.c @@ -1,4 +1,4 @@ -/* Copyright (C) 1997 Free Software Foundation, Inc. +/* Copyright (C) 1997, 1999 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1997. @@ -25,6 +25,7 @@ #include #include "nss-nisplus.h" +#include "nisplus-parser.h" __libc_lock_define_initialized (static, lock) @@ -32,9 +33,6 @@ static nis_result *result = NULL; static nis_name tablename_val = NULL; static u_long tablename_len = 0; -extern int _nss_nisplus_parse_pwent (nis_result *res, struct passwd *pw, - char *buffer, size_t buflen, int *errnop); - static enum nss_status _nss_create_tablename (int *errnop) { diff --git a/sunrpc/rpc/xdr.h b/sunrpc/rpc/xdr.h index 44e30dfabe..8e74d3cd7f 100644 --- a/sunrpc/rpc/xdr.h +++ b/sunrpc/rpc/xdr.h @@ -82,12 +82,11 @@ __BEGIN_DECLS * XDR_FREE can be used to release the space allocated by an XDR_DECODE * request. */ -enum xdr_op - { - XDR_ENCODE = 0, - XDR_DECODE = 1, - XDR_FREE = 2 - }; +enum xdr_op { + XDR_ENCODE = 0, + XDR_DECODE = 1, + XDR_FREE = 2 +}; /* * This is the number of bytes per unit of external data. @@ -135,6 +134,10 @@ struct XDR /* buf quick ptr to buffered data */ void (*x_destroy) __PMT ((XDR *__xdrs)); /* free privates of this xdr_stream */ + bool_t (*x_getint32) __PMT ((XDR *__xdrs, int32_t *__ip)); + /* get a int from underlying stream */ + bool_t (*x_putint32) __PMT ((XDR *__xdrs, __const int32_t *__ip)); + /* put a int to " */ } *x_ops; caddr_t x_public; /* users' data */ @@ -165,14 +168,14 @@ typedef bool_t (*xdrproc_t) __PMT ((XDR *, void *,...)); * u_int pos; */ #define XDR_GETINT32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p) + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) #define xdr_getint32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_getlong)(xdrs, (long *)int32p) + (*(xdrs)->x_ops->x_getint32)(xdrs, int32p) #define XDR_PUTINT32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p) + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) #define xdr_putint32(xdrs, int32p) \ - (*(xdrs)->x_ops->x_putlong)(xdrs, (long *)int32p) + (*(xdrs)->x_ops->x_putint32)(xdrs, int32p) #define XDR_GETLONG(xdrs, longp) \ (*(xdrs)->x_ops->x_getlong)(xdrs, longp) diff --git a/sunrpc/svc_tcp.c b/sunrpc/svc_tcp.c index cd5cecf0f7..cd24f726c9 100644 --- a/sunrpc/svc_tcp.c +++ b/sunrpc/svc_tcp.c @@ -312,8 +312,11 @@ readtcp (char *xprtptr, char *buf, int len) case 0: goto fatal_err; default: + if ((pollfd.revents & POLLERR) || (pollfd.revents & POLLHUP) + || (pollfd.revents & POLLNVAL)) + goto fatal_err; break; - } + } } while ((pollfd.revents & POLLIN) == 0); diff --git a/sunrpc/xdr_mem.c b/sunrpc/xdr_mem.c index 47b87eaf7a..9379048bf7 100644 --- a/sunrpc/xdr_mem.c +++ b/sunrpc/xdr_mem.c @@ -54,6 +54,8 @@ static u_int xdrmem_getpos (const XDR *); static bool_t xdrmem_setpos (XDR *, u_int); static long *xdrmem_inline (XDR *, int); static void xdrmem_destroy (XDR *); +static bool_t xdrmem_getint32 (XDR *, int32_t *); +static bool_t xdrmem_putint32 (XDR *, const int32_t *); static const struct xdr_ops xdrmem_ops = { @@ -64,7 +66,9 @@ static const struct xdr_ops xdrmem_ops = xdrmem_getpos, xdrmem_setpos, xdrmem_inline, - xdrmem_destroy + xdrmem_destroy, + xdrmem_getint32, + xdrmem_putint32 }; /* @@ -219,3 +223,35 @@ xdrmem_inline (xdrs, len) } return buf; } + +/* + * Gets the next word from the memory referenced by xdrs and places it + * in the int pointed to by ip. It then increments the private word to + * point at the next element. Neither object pointed to is const + */ +static bool_t +xdrmem_getint32 (XDR *xdrs, int32_t *ip) +{ + + if ((xdrs->x_handy -= 4) < 0) + return FALSE; + *ip = ntohl ((*((int32_t *) (xdrs->x_private)))); + xdrs->x_private += 4; + return TRUE; +} + +/* + * Puts the long pointed to by lp in the memory referenced by xdrs. It + * then increments the private word to point at the next element. The + * long pointed at is const + */ +static bool_t +xdrmem_putint32 (XDR *xdrs, const int32_t *ip) +{ + + if ((xdrs->x_handy -= 4) < 0) + return FALSE; + *(int32_t *) xdrs->x_private = htonl (*ip); + xdrs->x_private += 4; + return TRUE; +} diff --git a/sunrpc/xdr_rec.c b/sunrpc/xdr_rec.c index 30be6393a2..e0f22c5595 100644 --- a/sunrpc/xdr_rec.c +++ b/sunrpc/xdr_rec.c @@ -66,6 +66,8 @@ static u_int xdrrec_getpos (const XDR *); static bool_t xdrrec_setpos (XDR *, u_int); static long *xdrrec_inline (XDR *, int); static void xdrrec_destroy (XDR *); +static bool_t xdrrec_getint32 (XDR *, int32_t *); +static bool_t xdrrec_putint32 (XDR *, const int32_t *); static const struct xdr_ops xdrrec_ops = { @@ -76,7 +78,9 @@ static const struct xdr_ops xdrrec_ops = xdrrec_getpos, xdrrec_setpos, xdrrec_inline, - xdrrec_destroy + xdrrec_destroy, + xdrrec_getint32, + xdrrec_putint32 }; /* @@ -251,11 +255,8 @@ xdrrec_putlong (xdrs, lp) return TRUE; } -static bool_t /* must manage buffers, fragments, and records */ -xdrrec_getbytes (xdrs, addr, len) - XDR *xdrs; - caddr_t addr; - u_int len; +static bool_t /* must manage buffers, fragments, and records */ +xdrrec_getbytes (XDR *xdrs, caddr_t addr, u_int len) { RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; u_int current; @@ -420,6 +421,53 @@ xdrrec_destroy (xdrs) mem_free ((caddr_t) rstrm, sizeof (RECSTREAM)); } +static bool_t +xdrrec_getint32 (XDR *xdrs, int32_t *ip) +{ + RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; + int32_t *bufip = (int32_t *) rstrm->in_finger; + int32_t mylong; + + /* first try the inline, fast case */ + if (rstrm->fbtbc >= BYTES_PER_XDR_UNIT && + rstrm->in_boundry - (char *) bufip >= BYTES_PER_XDR_UNIT) + { + *ip = ntohl (*bufip); + rstrm->fbtbc -= BYTES_PER_XDR_UNIT; + rstrm->in_finger += BYTES_PER_XDR_UNIT; + } + else + { + if (!xdrrec_getbytes (xdrs, (caddr_t) &mylong, + BYTES_PER_XDR_UNIT)) + return FALSE; + *ip = ntohl (mylong); + } + return TRUE; +} + +static bool_t +xdrrec_putint32 (XDR *xdrs, const int32_t *ip) +{ + RECSTREAM *rstrm = (RECSTREAM *) xdrs->x_private; + int32_t *dest_ip = (int32_t *) rstrm->out_finger; + + if ((rstrm->out_finger += BYTES_PER_XDR_UNIT) > rstrm->out_boundry) + { + /* + * this case should almost never happen so the code is + * inefficient + */ + rstrm->out_finger -= BYTES_PER_XDR_UNIT; + rstrm->frag_sent = TRUE; + if (!flush_out (rstrm, FALSE)) + return FALSE; + dest_ip = (int32_t *) rstrm->out_finger; + rstrm->out_finger += BYTES_PER_XDR_UNIT; + } + *dest_ip = htonl (*ip); + return TRUE; +} /* * Exported routines to manage xdr records diff --git a/sunrpc/xdr_sizeof.c b/sunrpc/xdr_sizeof.c index 72403e0a26..e999e0ef51 100644 --- a/sunrpc/xdr_sizeof.c +++ b/sunrpc/xdr_sizeof.c @@ -123,6 +123,13 @@ x_destroy (XDR *xdrs) return; } +static bool_t +x_putint32 (XDR *xdrs, const int32_t *int32p) +{ + xdrs->x_handy += BYTES_PER_XDR_UNIT; + return TRUE; +} + unsigned long xdr_sizeof (xdrproc_t func, void *data) { @@ -132,6 +139,7 @@ xdr_sizeof (xdrproc_t func, void *data) /* to stop ANSI-C compiler from complaining */ typedef bool_t (*dummyfunc1) (XDR *, long *); typedef bool_t (*dummyfunc2) (XDR *, caddr_t, u_int); + typedef bool_t (*dummyfunc3) (XDR *, int32_t *); ops.x_putlong = x_putlong; ops.x_putbytes = x_putbytes; @@ -139,10 +147,12 @@ xdr_sizeof (xdrproc_t func, void *data) ops.x_getpostn = x_getpostn; ops.x_setpostn = x_setpostn; ops.x_destroy = x_destroy; + ops.x_putint32 = x_putint32; /* the other harmless ones */ ops.x_getlong = (dummyfunc1) harmless; ops.x_getbytes = (dummyfunc2) harmless; + ops.x_getint32 = (dummyfunc3) harmless; x.x_op = XDR_ENCODE; x.x_ops = &ops; diff --git a/sunrpc/xdr_stdio.c b/sunrpc/xdr_stdio.c index 8588042eeb..e58137c559 100644 --- a/sunrpc/xdr_stdio.c +++ b/sunrpc/xdr_stdio.c @@ -61,6 +61,8 @@ static u_int xdrstdio_getpos (const XDR *); static bool_t xdrstdio_setpos (XDR *, u_int); static long *xdrstdio_inline (XDR *, int); static void xdrstdio_destroy (XDR *); +static bool_t xdrstdio_getint32 (XDR *, int32_t *); +static bool_t xdrstdio_putint32 (XDR *, const int32_t *); /* * Ops vector for stdio type XDR @@ -74,7 +76,9 @@ static const struct xdr_ops xdrstdio_ops = xdrstdio_getpos, /* get offset in the stream */ xdrstdio_setpos, /* set offset in the stream */ xdrstdio_inline, /* prime stream for inline macros */ - xdrstdio_destroy /* destroy stream */ + xdrstdio_destroy, /* destroy stream */ + xdrstdio_getint32, /* deserialize a int */ + xdrstdio_putint32 /* serialize a int */ }; /* @@ -181,3 +185,25 @@ xdrstdio_inline (XDR *xdrs, int len) */ return NULL; } + +static bool_t +xdrstdio_getint32 (XDR *xdrs, int32_t *ip) +{ + int32_t mycopy; + + if (fread ((caddr_t) &mycopy, 4, 1, (FILE *) xdrs->x_private) != 1) + return FALSE; + *ip = ntohl (mycopy); + return TRUE; +} + +static bool_t +xdrstdio_putint32 (XDR *xdrs, const int32_t *ip) +{ + int32_t mycopy = htonl (*ip); + + ip = &mycopy; + if (fwrite ((caddr_t) ip, 4, 1, (FILE *) xdrs->x_private) != 1) + return FALSE; + return TRUE; +} diff --git a/sysdeps/unix/sysv/linux/ttyname.c b/sysdeps/unix/sysv/linux/ttyname.c index 9d345b8b94..20c794daf4 100644 --- a/sysdeps/unix/sysv/linux/ttyname.c +++ b/sysdeps/unix/sysv/linux/ttyname.c @@ -107,11 +107,10 @@ ttyname (fd) { static char *buf; static size_t buflen = 0; - static int dev_pts_available = 1; char procname[30]; struct stat st, st1; int dostat = 0; - char *name = NULL; + char *name; int save = errno; if (!__isatty (fd)) @@ -139,21 +138,18 @@ ttyname (fd) if (__fxstat (_STAT_VER, fd, &st) < 0) return NULL; - if (dev_pts_available) + if (__xstat (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode)) { - if (__xstat (_STAT_VER, "/dev/pts", &st1) == 0 && S_ISDIR (st1.st_mode)) - { #ifdef _STATBUF_ST_RDEV - name = getttyname ("/dev/pts", st.st_rdev, st.st_ino, save, &dostat); + name = getttyname ("/dev/pts", st.st_rdev, st.st_ino, save, &dostat); #else - name = getttyname ("/dev/pts", st.st_dev, st.st_ino, save, &dostat); + name = getttyname ("/dev/pts", st.st_dev, st.st_ino, save, &dostat); #endif - } - else - { - __set_errno (save); - dev_pts_available = 0; - } + } + else + { + __set_errno (save); + name = NULL; } if (!name && dostat != -1) diff --git a/sysdeps/unix/sysv/linux/ttyname_r.c b/sysdeps/unix/sysv/linux/ttyname_r.c index 3255ce3e00..b92c712fcc 100644 --- a/sysdeps/unix/sysv/linux/ttyname_r.c +++ b/sysdeps/unix/sysv/linux/ttyname_r.c @@ -103,7 +103,6 @@ __ttyname_r (fd, buf, buflen) char *buf; size_t buflen; { - static int dev_pts_available = 1; char procname[30]; struct stat st, st1; int dostat = 0; @@ -149,24 +148,20 @@ __ttyname_r (fd, buf, buflen) memcpy (buf, "/dev/pts/", sizeof ("/dev/pts/")); buflen -= sizeof ("/dev/pts/") - 1; - if (dev_pts_available) + if (__xstat (_STAT_VER, buf, &st1) == 0 && S_ISDIR (st1.st_mode)) { - if (__xstat (_STAT_VER, buf, &st1) == 0 && S_ISDIR (st1.st_mode)) - { #ifdef _STATBUF_ST_RDEV - ret = getttyname_r (buf, buflen, st.st_rdev, st.st_ino, save, - &dostat); + ret = getttyname_r (buf, buflen, st.st_rdev, st.st_ino, save, + &dostat); #else - ret = getttyname_r (buf, buflen, st.st_dev, st.st_ino, save, - &dostat); + ret = getttyname_r (buf, buflen, st.st_dev, st.st_ino, save, + &dostat); #endif - } - else - { - __set_errno (save); - ret = ENOENT; - dev_pts_available = 0; - } + } + else + { + __set_errno (save); + ret = ENOENT; } if (ret && dostat != -1)