diff options
author | Damien Miller <djm@mindrot.org> | 1999-11-22 13:57:07 +1100 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 1999-11-22 13:57:07 +1100 |
commit | b3ca3aa12f8248c2d9e23f15a46e0f3c97397e54 (patch) | |
tree | 7833695d2f077b965b02a5b9927be50456d172d7 | |
parent | a75cb9666237b3479471238eb26b39872b9858e0 (diff) |
- Added OpenBSD bsd-strlcat.c, created bsd-strlcat.h
- Added timersum() macro
- Tidy RCSIDs of bsd-*.c
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | Makefile.in | 6 | ||||
-rw-r--r-- | acconfig.h | 17 | ||||
-rw-r--r-- | bsd-login.c | 2 | ||||
-rw-r--r-- | bsd-strlcat.c | 76 | ||||
-rw-r--r-- | bsd-strlcat.h | 10 | ||||
-rw-r--r-- | configure.in | 4 | ||||
-rw-r--r-- | includes.h | 5 |
8 files changed, 116 insertions, 7 deletions
@@ -5,6 +5,9 @@ don't create ~/.ssh only if the user wants to store the private key there. show fingerprint instead of public-key after keygeneration. ok niels@ + - Added OpenBSD bsd-strlcat.c, created bsd-strlcat.h + - Added timersum() macro + - Tidy RCSIDs of bsd-*.c 19991121 - OpenBSD CVS Changes: diff --git a/Makefile.in b/Makefile.in index b338c9ca..4400c258 100644 --- a/Makefile.in +++ b/Makefile.in @@ -28,12 +28,12 @@ OBJS= authfd.o authfile.o auth-passwd.o auth-rhosts.o auth-rh-rsa.o \ hostfile.o log-client.o login.o log-server.o match.o mpaux.o \ packet.o pty.o readconf.o readpass.o rsa.o servconf.o serverloop.o \ sshconnect.o tildexpand.o ttymodes.o uidswap.o xmalloc.o \ - helper.o bsd-mktemp.o bsd-strlcpy.o bsd-daemon.o bsd-login.o rc4.o \ - md5crypt.o + helper.o bsd-mktemp.o bsd-strlcpy.o bsd-strlcat.o bsd-daemon.o \ + bsd-login.o rc4.o md5crypt.o all: $(OBJS) $(TARGETS) -libssh.a: authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o hostfile.o match.o mpaux.o nchan.o packet.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o helper.o rc4.o bsd-mktemp.o bsd-strlcpy.o log.o fingerprint.o +libssh.a: authfd.o authfile.o bufaux.o buffer.o canohost.o channels.o cipher.o compat.o compress.o crc32.o deattack.o hostfile.o match.o mpaux.o nchan.o packet.o readpass.o rsa.o tildexpand.o ttymodes.o uidswap.o xmalloc.o helper.o rc4.o bsd-mktemp.o bsd-strlcpy.o bsd-strlcat.o log.o fingerprint.o $(AR) rv $@ $^ $(RANLIB) $@ @@ -71,6 +71,10 @@ # include <paths.h> /* For _PATH_XXX */ #endif +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> /* For timersub */ +#endif + #ifndef SHUT_RDWR enum { @@ -178,3 +182,16 @@ enum # define MAX(a,b) (((a)>(b))?(a):(b)) # define MIN(a,b) (((a)<(b))?(a):(b)) #endif + +#ifndef timersub +#define timersub(a, b, result) \ + do { \ + (result)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ + (result)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ + if ((result)->tv_usec < 0) { \ + --(result)->tv_sec; \ + (result)->tv_usec += 1000000; \ + } \ + } while (0) + +#endif diff --git a/bsd-login.c b/bsd-login.c index 98010ec3..93f23026 100644 --- a/bsd-login.c +++ b/bsd-login.c @@ -37,7 +37,7 @@ #if defined(LIBC_SCCS) && !defined(lint) /* from: static char sccsid[] = "@(#)login.c 8.1 (Berkeley) 6/4/93"; */ -static char *rcsid = "$Id: bsd-login.c,v 1.2 1999/11/20 01:18:40 damien Exp $"; +static char *rcsid = "$OpenBSD: login.c,v 1.5 1998/07/13 02:11:12 millert Exp $"; #endif /* LIBC_SCCS and not lint */ #include <sys/types.h> diff --git a/bsd-strlcat.c b/bsd-strlcat.c new file mode 100644 index 00000000..10ad9e71 --- /dev/null +++ b/bsd-strlcat.c @@ -0,0 +1,76 @@ +/* $OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $ */ + +/* + * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com> + * 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. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``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 AUTHOR 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. + */ + +#include "config.h" +#ifndef HAVE_STRLCAT + +#if defined(LIBC_SCCS) && !defined(lint) +static char *rcsid = "$OpenBSD: strlcat.c,v 1.2 1999/06/17 16:28:58 millert Exp $"; +#endif /* LIBC_SCCS and not lint */ + +#include <sys/types.h> +#include <string.h> + +/* + * Appends src to string dst of size siz (unlike strncat, siz is the + * full size of dst, not space left). At most siz-1 characters + * will be copied. Always NUL terminates (unless siz == 0). + * Returns strlen(src); if retval >= siz, truncation occurred. + */ +size_t strlcat(dst, src, siz) + char *dst; + const char *src; + size_t siz; +{ + register char *d = dst; + register const char *s = src; + register size_t n = siz; + size_t dlen; + + /* Find the end of dst and adjust bytes left but don't go past end */ + while (*d != '\0' && n-- != 0) + d++; + dlen = d - dst; + n = siz - dlen; + + if (n == 0) + return(dlen + strlen(s)); + while (*s != '\0') { + if (n != 1) { + *d++ = *s; + n--; + } + s++; + } + *d = '\0'; + + return(dlen + (s - src)); /* count does not include NUL */ +} + +#endif /* !HAVE_STRLCAT */ diff --git a/bsd-strlcat.h b/bsd-strlcat.h new file mode 100644 index 00000000..562dc704 --- /dev/null +++ b/bsd-strlcat.h @@ -0,0 +1,10 @@ +#ifndef _BSD_STRLCAT_H +#define _BSD_STRLCAT_H + +#include "config.h" +#ifndef HAVE_STRLCAT +#include <sys/types.h> +size_t strlcat(char *dst, const char *src, size_t siz); +#endif /* !HAVE_STRLCAT */ + +#endif /* _BSD_STRLCAT_H */ diff --git a/configure.in b/configure.in index 2a4a2c7d..1fe0c30b 100644 --- a/configure.in +++ b/configure.in @@ -55,10 +55,10 @@ AC_CHECK_LIB(dl, dlopen, , ) AC_CHECK_LIB(pam, pam_authenticate, , ) dnl Checks for header files. -AC_CHECK_HEADERS(pty.h endian.h paths.h lastlog.h shadow.h netgroup.h maillock.h sys/select.h) +AC_CHECK_HEADERS(pty.h endian.h paths.h lastlog.h shadow.h netgroup.h maillock.h sys/select.h sys/time.h) dnl Checks for library functions. -AC_CHECK_FUNCS(openpty strlcpy mkdtemp arc4random setproctitle setlogin) +AC_CHECK_FUNCS(openpty strlcpy strlcat mkdtemp arc4random setproctitle setlogin) AC_CHECK_FUNC(login, [AC_DEFINE(HAVE_LOGIN)], @@ -27,7 +27,6 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #include <sys/ioctl.h> #include <sys/stat.h> #include <sys/wait.h> -#include <sys/time.h> #include <sys/un.h> #include <sys/resource.h> @@ -65,6 +64,9 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #ifdef HAVE_SYS_SELECT_H # include <sys/select.h> #endif +#ifdef HAVE_SYS_TIME_H +# include <sys/time.h> +#endif #ifdef HAVE_LIBPAM # include <security/pam_appl.h> #endif @@ -72,6 +74,7 @@ static /**/const char *const rcsid[] = { (char *)rcsid, "\100(#)" msg } #include "version.h" #include "helper.h" #include "bsd-strlcpy.h" +#include "bsd-strlcat.h" #include "bsd-mktemp.h" /* Define this to be the path of the xauth program. */ |