diff options
Diffstat (limited to 'crypto/heimdal/lib/roken')
-rw-r--r-- | crypto/heimdal/lib/roken/ChangeLog | 74 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/Makefile.am | 5 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/Makefile.in | 32 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/bswap.c | 61 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/freeaddrinfo.c | 11 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/getaddrinfo-test.c | 6 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/getarg.c | 31 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/getarg.h | 6 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/getifaddrs.c | 4 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/getnameinfo.c | 6 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/getnameinfo_verified.c | 19 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/glob.c | 61 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/glob.hin | 1 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/inet_ntop.c | 11 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/parse_units.c | 7 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/print_version.c | 4 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/roken.awk | 17 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/roken.h.in | 30 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/warnerr.c | 30 | ||||
-rw-r--r-- | crypto/heimdal/lib/roken/write_pid.c | 4 |
20 files changed, 335 insertions, 85 deletions
diff --git a/crypto/heimdal/lib/roken/ChangeLog b/crypto/heimdal/lib/roken/ChangeLog index 2e3ee9d..cbc7393 100644 --- a/crypto/heimdal/lib/roken/ChangeLog +++ b/crypto/heimdal/lib/roken/ChangeLog @@ -1,3 +1,77 @@ +2001-05-17 Assar Westerlund <assar@sics.se> + + * Makefile.am: bump version to 12:0:3 + * roken.h.in: re-add set_progname and get_progname for backwards + compatability + * warnerr.c: re-add set_progname and get_progname for backwards + compatability + +2001-05-12 Assar Westerlund <assar@sics.se> + + * glob.c: add limits.h, from <shadow@dementia.org> + +2001-05-11 Johan Danielsson <joda@pdc.kth.se> + + * Makefile.am: bswap.c + + * bswap.c: bswap{16,32} + +2001-05-08 Assar Westerlund <assar@sics.se> + + * freeaddrinfo.c (freeaddrinfo): also free every `struct + addrinfo'. from <tmartin@mirapoint.com> + +2001-04-25 Assar Westerlund <assar@sics.se> + + * getarg.h (free_getarg_strings): add prototype + * getarg.c (free_getarg_strings): add function + +2001-04-21 Johan Danielsson <joda@pdc.kth.se> + + * getarg.c: pack short flag options togther, to shorten the usage + string + +2001-04-17 Johan Danielsson <joda@pdc.kth.se> + + * getifaddrs.c (getifaddrs2): close socket when done + +2001-03-26 Johan Danielsson <joda@pdc.kth.se> + + * roken.awk: END has to be last with Sun's awk + +2001-03-26 Assar Westerlund <assar@sics.se> + + * parse_units.c (parse_something): do not check the return value + from strtod, it might return != 0.0 when the string has no digits. + just testing if it consumed any characters is enough and more + resilient + * glob.c: add GLOB_LIMIT (from NetBSD) + +2001-02-20 Assar Westerlund <assar@sics.se> + + * warnerr.c (warnerr): do not use __progname + * roken.h.in (setprogname, getprogname): add prototypes + * warnerr.c (setprogname, getprogname): rename to. change all + callers + +2001-02-12 Assar Westerlund <assar@sics.se> + + * getnameinfo_verified.c (getnameinfo_verified): do the first + getnameinfo with NI_NUMERICSERV to avoid the error that bind 8.2.3 + reports on not finding the service + (ENI_NOSERVNAME). reported by Ake Sandgren <ake@cs.umu.se> + +2001-02-09 Assar Westerlund <assar@sics.se> + + * getnameinfo.c (doit): call inet_ntop with correct af, noted by + Ake Sandgren <ake@cs.umu.se> + +2001-02-08 Assar Westerlund <assar@sics.se> + + * getnameinfo_verified.c (getnameinfo_verified): always capture + the service from getnameinfo so it can be sent back to getaddrinfo + and set socktype to avoid getaddrinfo not returning any addresses + 2001-01-30 Assar Westerlund <assar@sics.se> * Makefile.am (libroken_la_LDFLAGS): bump version to 11:1:2 diff --git a/crypto/heimdal/lib/roken/Makefile.am b/crypto/heimdal/lib/roken/Makefile.am index 23f2d59..ce874b0 100644 --- a/crypto/heimdal/lib/roken/Makefile.am +++ b/crypto/heimdal/lib/roken/Makefile.am @@ -1,4 +1,4 @@ -# $Id: Makefile.am,v 1.94 2001/01/30 01:53:30 assar Exp $ +# $Id: Makefile.am,v 1.96 2001/05/16 23:57:10 assar Exp $ AUTOMAKE_OPTIONS = foreign no-dependencies @@ -10,7 +10,7 @@ ACLOCAL_AMFLAGS = -I ../../cf CLEANFILES = roken.h make-roken.c $(XHEADERS) lib_LTLIBRARIES = libroken.la -libroken_la_LDFLAGS = -version-info 11:1:2 +libroken_la_LDFLAGS = -version-info 12:0:3 noinst_PROGRAMS = make-roken @@ -34,6 +34,7 @@ parse_bytes_test_LDADD = $(common_LDADD) libroken_la_SOURCES = \ base64.c \ + bswap.c \ concat.c \ emalloc.c \ environment.c \ diff --git a/crypto/heimdal/lib/roken/Makefile.in b/crypto/heimdal/lib/roken/Makefile.in index c779d46..b72df46 100644 --- a/crypto/heimdal/lib/roken/Makefile.in +++ b/crypto/heimdal/lib/roken/Makefile.in @@ -1,6 +1,7 @@ -# Makefile.in generated automatically by automake 1.4a from Makefile.am +# Makefile.in generated automatically by automake 1.4b from Makefile.am -# Copyright (C) 1994, 1995-9, 2000 Free Software Foundation, Inc. +# Copyright 1994, 1995, 1996, 1997, 1998, 1999, 2000 +# Free Software Foundation, Inc. # This Makefile.in is free software; the Free Software Foundation # gives unlimited permission to copy and/or distribute it, # with or without modifications, as long as this notice is preserved. @@ -113,7 +114,7 @@ dpagaix_CFLAGS = @dpagaix_CFLAGS@ dpagaix_LDADD = @dpagaix_LDADD@ install_sh = @install_sh@ -# $Id: Makefile.am,v 1.94 2001/01/30 01:53:30 assar Exp $ +# $Id: Makefile.am,v 1.96 2001/05/16 23:57:10 assar Exp $ AUTOMAKE_OPTIONS = foreign no-dependencies @@ -125,7 +126,7 @@ ACLOCAL_AMFLAGS = -I ../../cf CLEANFILES = roken.h make-roken.c $(XHEADERS) lib_LTLIBRARIES = libroken.la -libroken_la_LDFLAGS = -version-info 11:1:2 +libroken_la_LDFLAGS = -version-info 12:0:3 noinst_PROGRAMS = make-roken @@ -148,6 +149,7 @@ parse_bytes_test_LDADD = $(common_LDADD) libroken_la_SOURCES = \ base64.c \ + bswap.c \ concat.c \ emalloc.c \ environment.c \ @@ -314,8 +316,8 @@ X_LIBS = @X_LIBS@ X_EXTRA_LIBS = @X_EXTRA_LIBS@ X_PRE_LIBS = @X_PRE_LIBS@ libroken_la_DEPENDENCIES = @LTLIBOBJS@ -am_libroken_la_OBJECTS = base64.lo concat.lo emalloc.lo environment.lo \ -eread.lo erealloc.lo esetenv.lo estrdup.lo ewrite.lo \ +am_libroken_la_OBJECTS = base64.lo bswap.lo concat.lo emalloc.lo \ +environment.lo eread.lo erealloc.lo esetenv.lo estrdup.lo ewrite.lo \ getaddrinfo_hostspec.lo get_default_username.lo get_window_size.lo \ getarg.lo getnameinfo_verified.lo issuid.lo k_getpwnam.lo k_getpwuid.lo \ mini_inetd.lo net_read.lo net_write.lo parse_bytes.lo parse_time.lo \ @@ -358,7 +360,7 @@ HEADERS = $(include_HEADERS) $(nodist_include_HEADERS) depcomp = DIST_COMMON = $(include_HEADERS) ChangeLog Makefile.am Makefile.in \ -acinclude.m4 getcap.c getcwd.c getnameinfo.c glob.c install-sh \ +acinclude.m4 getcap.c getnameinfo.c glob.c install-sh \ make-print-version.c missing mkinstalldirs @@ -370,7 +372,7 @@ OBJECTS = $(am_libroken_la_OBJECTS) getaddrinfo-test.$(OBJEXT) $(nodist_make_rok all: all-redirect .SUFFIXES: -.SUFFIXES: .c .h .hin .lo .o .obj +.SUFFIXES: .hin .c .h .lo .o .obj $(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --foreign lib/roken/Makefile @@ -529,6 +531,11 @@ TAGS: $(HEADERS) $(SOURCES) $(TAGS_DEPENDENCIES) \ test -z "$(ETAGS_ARGS)$$unique$(LISP)$$tags" \ || etags $(ETAGS_ARGS) $$tags $$unique $(LISP) +GTAGS: + here=`CDPATH=: && cd $(top_builddir) && pwd` \ + && cd $(top_srcdir) \ + && gtags -i $$here + mostlyclean-tags: clean-tags: @@ -616,6 +623,9 @@ check-am: all-am check: check-am installcheck-am: installcheck: installcheck-am +all-recursive-am: $(BUILT_SOURCES) + $(MAKE) $(AM_MAKEFLAGS) all-recursive + install-exec-am: install-libLTLIBRARIES install-exec: install-exec-am @@ -693,9 +703,9 @@ maintainer-clean-noinstPROGRAMS uninstall-includeHEADERS \ install-includeHEADERS uninstall-nodist_includeHEADERS \ install-nodist_includeHEADERS tags mostlyclean-tags distclean-tags \ clean-tags maintainer-clean-tags check-TESTS distdir info-am info \ -dvi-am dvi check check-am installcheck-am installcheck install-exec-am \ -install-exec install-data-am install-data install-am install \ -uninstall-am uninstall all-redirect all-am all install-strip \ +dvi-am dvi check check-am installcheck-am installcheck all-recursive-am \ +install-exec-am install-exec install-data-am install-data install-am \ +install uninstall-am uninstall all-redirect all-am all install-strip \ installdirs mostlyclean-generic distclean-generic clean-generic \ maintainer-clean-generic clean mostlyclean distclean maintainer-clean diff --git a/crypto/heimdal/lib/roken/bswap.c b/crypto/heimdal/lib/roken/bswap.c new file mode 100644 index 0000000..c57dc6f --- /dev/null +++ b/crypto/heimdal/lib/roken/bswap.c @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2001 Kungliga Tekniska Högskolan + * (Royal Institute of Technology, Stockholm, Sweden). + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * 3. Neither the name of the Institute nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#ifdef HAVE_CONFIG_H +#include <config.h> +#endif +#include "roken.h" + +RCSID("$Id: bswap.c,v 1.3 2001/05/18 15:32:11 joda Exp $"); + +#ifndef HAVE_BSWAP32 + +unsigned int +bswap32 (unsigned int val) +{ + return (val & 0xff) << 24 | + (val & 0xff00) << 8 | + (val & 0xff0000) >> 8 | + (val & 0xff000000) >> 24; +} +#endif + +#ifndef HAVE_BSWAP16 + +unsigned short +bswap16 (unsigned short val) +{ + return (val & 0xff) << 8 | + (val & 0xff00) >> 8; +} +#endif diff --git a/crypto/heimdal/lib/roken/freeaddrinfo.c b/crypto/heimdal/lib/roken/freeaddrinfo.c index f963d15..56124e5 100644 --- a/crypto/heimdal/lib/roken/freeaddrinfo.c +++ b/crypto/heimdal/lib/roken/freeaddrinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: freeaddrinfo.c,v 1.2 1999/12/03 04:10:06 assar Exp $"); +RCSID("$Id: freeaddrinfo.c,v 1.4 2001/05/11 09:10:32 joda Exp $"); #endif #include "roken.h" @@ -45,8 +45,13 @@ RCSID("$Id: freeaddrinfo.c,v 1.2 1999/12/03 04:10:06 assar Exp $"); void freeaddrinfo(struct addrinfo *ai) { - for (; ai != NULL; ai = ai->ai_next) { + struct addrinfo *tofree; + + while(ai != NULL) { free (ai->ai_canonname); free (ai->ai_addr); + tofree = ai; + ai = ai->ai_next; + free (tofree); } } diff --git a/crypto/heimdal/lib/roken/getaddrinfo-test.c b/crypto/heimdal/lib/roken/getaddrinfo-test.c index 0e3afc5..4274081 100644 --- a/crypto/heimdal/lib/roken/getaddrinfo-test.c +++ b/crypto/heimdal/lib/roken/getaddrinfo-test.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getaddrinfo-test.c,v 1.3 2000/07/08 14:22:09 assar Exp $"); +RCSID("$Id: getaddrinfo-test.c,v 1.4 2001/02/20 01:44:54 assar Exp $"); #endif #include "roken.h" @@ -112,7 +112,7 @@ main(int argc, char **argv) int optind = 0; int i; - set_progname (argv[0]); + setprogname (argv[0]); if (getarg (args, sizeof(args) / sizeof(args[0]), argc, argv, &optind)) @@ -122,7 +122,7 @@ main(int argc, char **argv) usage (0); if (version_flag) { - fprintf (stderr, "%s from %s-%s)\n", __progname, PACKAGE, VERSION); + fprintf (stderr, "%s from %s-%s)\n", getprogname(), PACKAGE, VERSION); return 0; } diff --git a/crypto/heimdal/lib/roken/getarg.c b/crypto/heimdal/lib/roken/getarg.c index 342388e..dc2df50 100644 --- a/crypto/heimdal/lib/roken/getarg.c +++ b/crypto/heimdal/lib/roken/getarg.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getarg.c,v 1.37 2000/12/25 17:03:15 assar Exp $"); +RCSID("$Id: getarg.c,v 1.40 2001/04/25 12:06:10 assar Exp $"); #endif #include <stdio.h> @@ -211,7 +211,7 @@ arg_printusage (struct getargs *args, struct winsize ws; if (progname == NULL) - progname = __progname; + progname = getprogname(); if(getenv("GETARGMANDOC")){ mandoc_template(args, num_args, progname, extra_string); @@ -223,6 +223,23 @@ arg_printusage (struct getargs *args, columns = 80; col = 0; col += fprintf (stderr, "Usage: %s", progname); + buf[0] = '\0'; + for (i = 0; i < num_args; ++i) { + if(args[i].short_name && ISFLAG(args[i])) { + char s[2]; + if(buf[0] == '\0') + strlcpy(buf, "[-", sizeof(buf)); + s[0] = args[i].short_name; + s[1] = '\0'; + strlcat(buf, s, sizeof(buf)); + } + } + if(buf[0] != '\0') { + strlcat(buf, "]", sizeof(buf)); + col = check_column(stderr, col, strlen(buf) + 1, columns); + col += fprintf(stderr, " %s", buf); + } + for (i = 0; i < num_args; ++i) { size_t len = 0; @@ -244,7 +261,7 @@ arg_printusage (struct getargs *args, col = check_column(stderr, col, strlen(buf) + 1, columns); col += fprintf(stderr, " %s", buf); } - if (args[i].short_name) { + if (args[i].short_name && !ISFLAG(args[i])) { snprintf(buf, sizeof(buf), "[-%c", args[i].short_name); len += 2; len += print_arg(buf + strlen(buf), sizeof(buf) - strlen(buf), @@ -528,6 +545,12 @@ getarg(struct getargs *args, size_t num_args, return ret; } +void +free_getarg_strings (getarg_strings *s) +{ + free (s->strings); +} + #if TEST int foo_flag = 2; int flag1 = 0; diff --git a/crypto/heimdal/lib/roken/getarg.h b/crypto/heimdal/lib/roken/getarg.h index 7fd374b..3892eb4 100644 --- a/crypto/heimdal/lib/roken/getarg.h +++ b/crypto/heimdal/lib/roken/getarg.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -31,7 +31,7 @@ * SUCH DAMAGE. */ -/* $Id: getarg.h,v 1.10 1999/12/02 16:58:46 joda Exp $ */ +/* $Id: getarg.h,v 1.11 2001/04/25 12:06:37 assar Exp $ */ #ifndef __GETARG_H__ #define __GETARG_H__ @@ -86,4 +86,6 @@ void arg_printusage (struct getargs *args, const char *progname, const char *extra_string); +void free_getarg_strings (getarg_strings *); + #endif /* __GETARG_H__ */ diff --git a/crypto/heimdal/lib/roken/getifaddrs.c b/crypto/heimdal/lib/roken/getifaddrs.c index e8e3e54..04935ed 100644 --- a/crypto/heimdal/lib/roken/getifaddrs.c +++ b/crypto/heimdal/lib/roken/getifaddrs.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getifaddrs.c,v 1.4 2001/01/28 23:02:46 assar Exp $"); +RCSID("$Id: getifaddrs.c,v 1.5 2001/04/17 08:27:47 joda Exp $"); #endif #include "roken.h" @@ -170,9 +170,11 @@ getifaddrs2(struct ifaddrs **ifap, } *ifap = start; + close(fd); free(buf); return 0; error_out: + close(fd); free(buf); errno = ret; return -1; diff --git a/crypto/heimdal/lib/roken/getnameinfo.c b/crypto/heimdal/lib/roken/getnameinfo.c index 7e2d232..0f0cbd1 100644 --- a/crypto/heimdal/lib/roken/getnameinfo.c +++ b/crypto/heimdal/lib/roken/getnameinfo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getnameinfo.c,v 1.2 1999/12/03 04:10:07 assar Exp $"); +RCSID("$Id: getnameinfo.c,v 1.3 2001/02/09 14:45:30 assar Exp $"); #endif #include "roken.h" @@ -64,7 +64,7 @@ doit (int af, } } else if (flags & NI_NAMEREQD) { return EAI_NONAME; - } else if (inet_ntop (AF_INET, addr, host, hostlen) == NULL) + } else if (inet_ntop (af, addr, host, hostlen) == NULL) return EAI_SYSTEM; } } diff --git a/crypto/heimdal/lib/roken/getnameinfo_verified.c b/crypto/heimdal/lib/roken/getnameinfo_verified.c index 30384ed..de3c8bf 100644 --- a/crypto/heimdal/lib/roken/getnameinfo_verified.c +++ b/crypto/heimdal/lib/roken/getnameinfo_verified.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 - 2000 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: getnameinfo_verified.c,v 1.3 2000/06/28 01:21:53 assar Exp $"); +RCSID("$Id: getnameinfo_verified.c,v 1.5 2001/02/12 13:55:07 assar Exp $"); #endif #include "roken.h" @@ -46,14 +46,25 @@ getnameinfo_verified(const struct sockaddr *sa, socklen_t salen, { int ret; struct addrinfo *ai, *a; + char servbuf[NI_MAXSERV]; + struct addrinfo hints; if (host == NULL) return EAI_NONAME; - ret = getnameinfo (sa, salen, host, hostlen, serv, servlen, flags); + if (serv == NULL) { + serv = servbuf; + servlen = sizeof(servbuf); + } + + ret = getnameinfo (sa, salen, host, hostlen, serv, servlen, + flags | NI_NUMERICSERV); if (ret) return ret; - ret = getaddrinfo (host, serv, NULL, &ai); + + memset (&hints, 0, sizeof(hints)); + hints.ai_socktype = SOCK_STREAM; + ret = getaddrinfo (host, serv, &hints, &ai); if (ret) return ret; for (a = ai; a != NULL; a = a->ai_next) { diff --git a/crypto/heimdal/lib/roken/glob.c b/crypto/heimdal/lib/roken/glob.c index 66e8ec6..e4bc0dc 100644 --- a/crypto/heimdal/lib/roken/glob.c +++ b/crypto/heimdal/lib/roken/glob.c @@ -87,6 +87,9 @@ #ifdef HAVE_UNISTD_H #include <unistd.h> #endif +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif #include "glob.h" #include "roken.h" @@ -145,16 +148,16 @@ static int compare (const void *, const void *); static void g_Ctoc (const Char *, char *); static int g_lstat (Char *, struct stat *, glob_t *); static DIR *g_opendir (Char *, glob_t *); -static Char *g_strchr (Char *, int); +static Char *g_strchr (const Char *, int); #ifdef notdef static Char *g_strcat (Char *, const Char *); #endif static int g_stat (Char *, struct stat *, glob_t *); static int glob0 (const Char *, glob_t *); -static int glob1 (Char *, glob_t *); -static int glob2 (Char *, Char *, Char *, glob_t *); -static int glob3 (Char *, Char *, Char *, Char *, glob_t *); -static int globextend (const Char *, glob_t *); +static int glob1 (Char *, glob_t *, size_t *); +static int glob2 (Char *, Char *, Char *, glob_t *, size_t *); +static int glob3 (Char *, Char *, Char *, Char *, glob_t *, size_t *); +static int globextend (const Char *, glob_t *, size_t *); static const Char * globtilde (const Char *, Char *, glob_t *); static int globexp1 (const Char *, glob_t *); static int globexp2 (const Char *, const Char *, glob_t *, int *); @@ -173,7 +176,7 @@ glob(const char *pattern, int c; Char *bufnext, *bufend, patbuf[MaxPathLen+1]; - patnext = (u_char *) pattern; + patnext = (const u_char *) pattern; if (!(flags & GLOB_APPEND)) { pglob->gl_pathc = 0; pglob->gl_pathv = NULL; @@ -224,7 +227,7 @@ static int globexp1(const Char *pattern, glob_t *pglob) if (pattern[0] == CHAR_LBRACE && pattern[1] == CHAR_RBRACE && pattern[2] == CHAR_EOS) return glob0(pattern, pglob); - while ((ptr = (const Char *) g_strchr((Char *) ptr, CHAR_LBRACE)) != NULL) + while ((ptr = (const Char *) g_strchr(ptr, CHAR_LBRACE)) != NULL) if (!globexp2(ptr, pattern, pglob, &rv)) return rv; @@ -405,6 +408,7 @@ glob0(const Char *pattern, glob_t *pglob) const Char *qpatnext; int c, err, oldpathc; Char *bufnext, patbuf[MaxPathLen+1]; + size_t limit = 0; qpatnext = globtilde(pattern, patbuf, pglob); oldpathc = pglob->gl_pathc; @@ -418,7 +422,7 @@ glob0(const Char *pattern, glob_t *pglob) if (c == CHAR_NOT) ++qpatnext; if (*qpatnext == CHAR_EOS || - g_strchr((Char *) qpatnext+1, CHAR_RBRACKET) == NULL) { + g_strchr(qpatnext+1, CHAR_RBRACKET) == NULL) { *bufnext++ = CHAR_LBRACKET; if (c == CHAR_NOT) --qpatnext; @@ -462,7 +466,7 @@ glob0(const Char *pattern, glob_t *pglob) qprintf("glob0:", patbuf); #endif - if ((err = glob1(patbuf, pglob)) != 0) + if ((err = glob1(patbuf, pglob, &limit)) != 0) return(err); /* @@ -475,7 +479,7 @@ glob0(const Char *pattern, glob_t *pglob) ((pglob->gl_flags & GLOB_NOCHECK) || ((pglob->gl_flags & GLOB_NOMAGIC) && !(pglob->gl_flags & GLOB_MAGCHAR)))) - return(globextend(pattern, pglob)); + return(globextend(pattern, pglob, &limit)); else if (!(pglob->gl_flags & GLOB_NOSORT)) qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, pglob->gl_pathc - oldpathc, sizeof(char *), compare); @@ -489,14 +493,14 @@ compare(const void *p, const void *q) } static int -glob1(Char *pattern, glob_t *pglob) +glob1(Char *pattern, glob_t *pglob, size_t *limit) { Char pathbuf[MaxPathLen+1]; /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */ if (*pattern == CHAR_EOS) return(0); - return(glob2(pathbuf, pathbuf, pattern, pglob)); + return(glob2(pathbuf, pathbuf, pattern, pglob, limit)); } /* @@ -514,7 +518,8 @@ glob1(Char *pattern, glob_t *pglob) #endif static int -glob2(Char *pathbuf, Char *pathend, Char *pattern, glob_t *pglob) +glob2(Char *pathbuf, Char *pathend, Char *pattern, glob_t *pglob, + size_t *limit) { struct stat sb; Char *p, *q; @@ -539,7 +544,7 @@ glob2(Char *pathbuf, Char *pathend, Char *pattern, glob_t *pglob) *pathend = CHAR_EOS; } ++pglob->gl_matchc; - return(globextend(pathbuf, pglob)); + return(globextend(pathbuf, pglob, limit)); } /* Find end of next segment, copy tentatively to pathend. */ @@ -557,14 +562,15 @@ glob2(Char *pathbuf, Char *pathend, Char *pattern, glob_t *pglob) while (*pattern == CHAR_SEP) *pathend++ = *pattern++; } else /* Need expansion, recurse. */ - return(glob3(pathbuf, pathend, pattern, p, pglob)); + return(glob3(pathbuf, pathend, pattern, p, pglob, + limit)); } - /* CHAR_NOTREACHED */ + /* NOTREACHED */ } static int glob3(Char *pathbuf, Char *pathend, Char *pattern, Char *restpattern, - glob_t *pglob) + glob_t *pglob, size_t *limit) { struct dirent *dp; DIR *dirp; @@ -614,7 +620,7 @@ glob3(Char *pathbuf, Char *pathend, Char *pattern, Char *restpattern, *pathend = CHAR_EOS; continue; } - err = glob2(pathbuf, --dc, restpattern, pglob); + err = glob2(pathbuf, --dc, restpattern, pglob, limit); if (err) break; } @@ -642,11 +648,11 @@ glob3(Char *pathbuf, Char *pathend, Char *pattern, Char *restpattern, * gl_pathv points to (gl_offs + gl_pathc + 1) items. */ static int -globextend(const Char *path, glob_t *pglob) +globextend(const Char *path, glob_t *pglob, size_t *limit) { char **pathv; int i; - u_int newsize; + size_t newsize, len; char *copy; const Char *p; @@ -667,11 +673,19 @@ globextend(const Char *path, glob_t *pglob) for (p = path; *p++;) continue; - if ((copy = malloc(p - path)) != NULL) { + len = (size_t)(p - path); + *limit += len; + if ((copy = malloc(len)) != NULL) { g_Ctoc(path, copy); pathv[pglob->gl_offs + pglob->gl_pathc++] = copy; } pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; + + if ((pglob->gl_flags & GLOB_LIMIT) && (newsize + *limit) >= ARG_MAX) { + errno = 0; + return(GLOB_NOSPACE); + } + return(copy == NULL ? GLOB_NOSPACE : 0); } @@ -739,6 +753,7 @@ globfree(glob_t *pglob) if (*pp) free(*pp); free(pglob->gl_pathv); + pglob->gl_pathv = NULL; } } @@ -781,11 +796,11 @@ g_stat(Char *fn, struct stat *sb, glob_t *pglob) } static Char * -g_strchr(Char *str, int ch) +g_strchr(const Char *str, int ch) { do { if (*str == ch) - return (str); + return (Char *)str; } while (*str++); return (NULL); } diff --git a/crypto/heimdal/lib/roken/glob.hin b/crypto/heimdal/lib/roken/glob.hin index bece48a..98d8796 100644 --- a/crypto/heimdal/lib/roken/glob.hin +++ b/crypto/heimdal/lib/roken/glob.hin @@ -74,6 +74,7 @@ typedef struct { #define GLOB_NOMAGIC 0x0200 /* GLOB_NOCHECK without magic chars (csh). */ #define GLOB_QUOTE 0x0400 /* Quote special chars with \. */ #define GLOB_TILDE 0x0800 /* Expand tilde names from the passwd file. */ +#define GLOB_LIMIT 0x1000 /* Limit memory used by matches to ARG_MAX */ #define GLOB_NOSPACE (-1) /* Malloc call failed. */ #define GLOB_ABEND (-2) /* Unignored error. */ diff --git a/crypto/heimdal/lib/roken/inet_ntop.c b/crypto/heimdal/lib/roken/inet_ntop.c index 382b351..63c99a5 100644 --- a/crypto/heimdal/lib/roken/inet_ntop.c +++ b/crypto/heimdal/lib/roken/inet_ntop.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1999 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: inet_ntop.c,v 1.4 2000/07/27 16:24:00 assar Exp $"); +RCSID("$Id: inet_ntop.c,v 1.5 2001/04/04 23:58:01 assar Exp $"); #endif #include <roken.h> @@ -92,7 +92,7 @@ inet_ntop_v6 (const void *src, char *dst, size_t size) return NULL; } for (i = 0; i < 8; ++i) { - int non_zerop = 1; + int non_zerop = 0; if (non_zerop || (ptr[0] >> 4)) { *dst++ = xdigits[ptr[0] >> 4]; @@ -106,10 +106,7 @@ inet_ntop_v6 (const void *src, char *dst, size_t size) *dst++ = xdigits[ptr[1] >> 4]; non_zerop = 1; } - if (non_zerop || (ptr[1] & 0x0F)) { - *dst++ = xdigits[ptr[1] & 0x0F]; - non_zerop = 1; - } + *dst++ = xdigits[ptr[1] & 0x0F]; if (i != 7) *dst++ = ':'; ptr += 2; diff --git a/crypto/heimdal/lib/roken/parse_units.c b/crypto/heimdal/lib/roken/parse_units.c index 34c5030..2b32ad6 100644 --- a/crypto/heimdal/lib/roken/parse_units.c +++ b/crypto/heimdal/lib/roken/parse_units.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998, 1999 Kungliga Tekniska Högskolan + * Copyright (c) 1997 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: parse_units.c,v 1.12 1999/12/02 16:58:51 joda Exp $"); +RCSID("$Id: parse_units.c,v 1.13 2001/03/26 00:47:06 assar Exp $"); #endif #include <stdio.h> @@ -84,7 +84,8 @@ parse_something (const char *s, const struct units *units, ++p; val = strtod (p, &next); /* strtol(p, &next, 0); */ - if (val == 0 && p == next) { + if (p == next) { + val = 0; if(!accept_no_val_p) return -1; no_val_p = 1; diff --git a/crypto/heimdal/lib/roken/print_version.c b/crypto/heimdal/lib/roken/print_version.c index 8b505fa..b5ce816 100644 --- a/crypto/heimdal/lib/roken/print_version.c +++ b/crypto/heimdal/lib/roken/print_version.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: print_version.c,v 1.7 2001/01/30 03:05:29 assar Exp $"); +RCSID("$Id: print_version.c,v 1.8 2001/02/20 01:44:55 assar Exp $"); #endif #include "roken.h" @@ -49,7 +49,7 @@ print_version(const char *progname) int i; if(progname == NULL) - progname = __progname; + progname = getprogname(); if(num_args == 0) msg = "no version information"; diff --git a/crypto/heimdal/lib/roken/roken.awk b/crypto/heimdal/lib/roken/roken.awk index c1676f7..057b4fd 100644 --- a/crypto/heimdal/lib/roken/roken.awk +++ b/crypto/heimdal/lib/roken/roken.awk @@ -1,4 +1,4 @@ -# $Id: roken.awk,v 1.6 2000/08/16 01:56:30 assar Exp $ +# $Id: roken.awk,v 1.7 2001/03/26 09:26:35 joda Exp $ BEGIN { print "#include <stdio.h>" @@ -14,13 +14,6 @@ BEGIN { print "puts(\"#define __ROKEN_H__\");" print "puts(\"\");" } -END { - print "puts(\"#define ROKEN_VERSION \" VERSION );" - print "puts(\"\");" - print "puts(\"#endif /* __ROKEN_H__ */\");" - print "return 0;" - print "}" -} $1 == "\#ifdef" || $1 == "\#ifndef" || $1 == "\#if" || $1 == "\#else" || $1 == "\#elif" || $1 == "\#endif" || $1 == "#ifdef" || $1 == "#ifndef" || $1 == "#if" || $1 == "#else" || $1 == "#elif" || $1 == "#endif" { print $0; @@ -37,3 +30,11 @@ $1 == "\#ifdef" || $1 == "\#ifndef" || $1 == "\#if" || $1 == "\#else" || $1 == " } print "puts(\"" s "\");" } + +END { + print "puts(\"#define ROKEN_VERSION \" VERSION );" + print "puts(\"\");" + print "puts(\"#endif /* __ROKEN_H__ */\");" + print "return 0;" + print "}" +} diff --git a/crypto/heimdal/lib/roken/roken.h.in b/crypto/heimdal/lib/roken/roken.h.in index b16ae5d..538a530 100644 --- a/crypto/heimdal/lib/roken/roken.h.in +++ b/crypto/heimdal/lib/roken/roken.h.in @@ -32,7 +32,7 @@ * SUCH DAMAGE. */ -/* $Id: roken.h.in,v 1.148 2001/01/27 05:28:09 assar Exp $ */ +/* $Id: roken.h.in,v 1.157 2001/05/18 18:00:12 assar Exp $ */ #include <stdio.h> #include <stdlib.h> @@ -47,9 +47,21 @@ struct sockaddr_dl; #ifdef HAVE_SYS_PARAM_H #include <sys/param.h> #endif +#ifdef HAVE_INTTYPES_H +#include <inttypes.h> +#endif #ifdef HAVE_SYS_TYPES_H #include <sys/types.h> #endif +#ifdef HAVE_SYS_BITYPES_H +#include <sys/bitypes.h> +#endif +#ifdef HAVE_BIND_BITYPES_H +#include <bind/bitypes.h> +#endif +#ifdef HAVE_NETINET_IN6_MACHTYPES_H +#include <netinet/in6_machtypes.h> +#endif #ifdef HAVE_UNISTD_H #include <unistd.h> #endif @@ -352,6 +364,14 @@ mkstemp(char *template); void pidfile (const char*); #endif +#ifndef HAVE_BSWAP32 +unsigned int bswap32(unsigned int); +#endif + +#ifndef HAVE_BSWAP16 +unsigned short bswap16(unsigned short); +#endif + #ifndef HAVE_FLOCK #ifndef LOCK_SH #define LOCK_SH 1 /* Shared lock */ @@ -587,6 +607,14 @@ struct hostent* roken_gethostbyaddr(const void*, size_t, int); #define roken_getsockname(a,b,c) getsockname(a, b, (void*)c) #endif +#ifndef HAVE_SETPROGNAME +void setprogname(const char *argv0); +#endif + +#ifndef HAVE_GETPROGNAME +const char *getprogname(void); +#endif + void set_progname(char *argv0); const char *get_progname(void); diff --git a/crypto/heimdal/lib/roken/warnerr.c b/crypto/heimdal/lib/roken/warnerr.c index f57c90e..0ebae25 100644 --- a/crypto/heimdal/lib/roken/warnerr.c +++ b/crypto/heimdal/lib/roken/warnerr.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Högskolan + * Copyright (c) 1995 - 2001 Kungliga Tekniska Högskolan * (Royal Institute of Technology, Stockholm, Sweden). * All rights reserved. * @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: warnerr.c,v 1.9 2000/07/25 09:54:05 joda Exp $"); +RCSID("$Id: warnerr.c,v 1.13 2001/05/16 23:54:19 assar Exp $"); #endif #include "roken.h" @@ -43,14 +43,17 @@ RCSID("$Id: warnerr.c,v 1.9 2000/07/25 09:54:05 joda Exp $"); const char *__progname; #endif +#ifndef HAVE_GETPROGNAME const char * -get_progname(void) +getprogname(void) { return __progname; } +#endif +#ifndef HAVE_SETPROGNAME void -set_progname(char *argv0) +setprogname(const char *argv0) { #ifndef HAVE___PROGNAME char *p; @@ -64,13 +67,28 @@ set_progname(char *argv0) __progname = p; #endif } +#endif /* HAVE_SETPROGNAME */ + +void +set_progname(char *argv0) +{ + setprogname ((const char *)argv0); +} + +const char * +get_progname (void) +{ + return getprogname (); +} void warnerr(int doerrno, const char *fmt, va_list ap) { int sverrno = errno; - if(__progname != NULL){ - fprintf(stderr, "%s", __progname); + const char *progname = getprogname(); + + if(progname != NULL){ + fprintf(stderr, "%s", progname); if(fmt != NULL || doerrno) fprintf(stderr, ": "); } diff --git a/crypto/heimdal/lib/roken/write_pid.c b/crypto/heimdal/lib/roken/write_pid.c index 7d4fa24..ce02506 100644 --- a/crypto/heimdal/lib/roken/write_pid.c +++ b/crypto/heimdal/lib/roken/write_pid.c @@ -33,7 +33,7 @@ #ifdef HAVE_CONFIG_H #include <config.h> -RCSID("$Id: write_pid.c,v 1.4 2000/08/04 11:19:41 joda Exp $"); +RCSID("$Id: write_pid.c,v 1.5 2001/02/20 01:44:55 assar Exp $"); #endif #include <stdio.h> @@ -88,7 +88,7 @@ pidfile(const char *basename) if(pidfile_path != NULL) return; if(basename == NULL) - basename = __progname; + basename = getprogname(); pidfile_path = pid_file_write(basename); atexit(pidfile_cleanup); } |