summaryrefslogtreecommitdiff
path: root/source4/heimdal/lib/roken
diff options
context:
space:
mode:
Diffstat (limited to 'source4/heimdal/lib/roken')
-rw-r--r--source4/heimdal/lib/roken/base64.c1
-rw-r--r--source4/heimdal/lib/roken/ct.c64
-rw-r--r--source4/heimdal/lib/roken/resolve.c2
-rw-r--r--source4/heimdal/lib/roken/rkpty.c2
-rw-r--r--source4/heimdal/lib/roken/roken-common.h2
-rw-r--r--source4/heimdal/lib/roken/roken.h.in34
-rw-r--r--source4/heimdal/lib/roken/vis.c6
7 files changed, 84 insertions, 27 deletions
diff --git a/source4/heimdal/lib/roken/base64.c b/source4/heimdal/lib/roken/base64.c
index bc74391b56..a9f0535dda 100644
--- a/source4/heimdal/lib/roken/base64.c
+++ b/source4/heimdal/lib/roken/base64.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <string.h>
+#include <limits.h>
#include "base64.h"
static const char base64_chars[] =
diff --git a/source4/heimdal/lib/roken/ct.c b/source4/heimdal/lib/roken/ct.c
new file mode 100644
index 0000000000..0778c2d474
--- /dev/null
+++ b/source4/heimdal/lib/roken/ct.c
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2009 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.
+ */
+
+#include <config.h>
+#include "roken.h"
+
+/**
+ * Constant time compare to memory regions. The reason for making it
+ * constant time is to make sure that timeing information leak from
+ * where in the function the diffrence is.
+ *
+ * ct_memcmp() can't be used to order memory regions like memcmp(),
+ * for example, use ct_memcmp() with qsort().
+ *
+ * @param p1 memory region 1 to compare
+ * @param p2 memory region 2 to compare
+ * @param len length of memory
+ *
+ * @return 0 when the memory regions are equal, non zero if not
+ *
+ * @ingroup roken
+ */
+
+int
+ct_memcmp(const void *p1, const void *p2, size_t len)
+{
+ const unsigned char *s1 = p1, *s2 = p2;
+ size_t i;
+ int r = 0;
+
+ for (i = 0; i < len; i++)
+ r |= (s1[i] ^ s2[i]);
+ return !!r;
+}
diff --git a/source4/heimdal/lib/roken/resolve.c b/source4/heimdal/lib/roken/resolve.c
index a74e438cf8..419c8d94e0 100644
--- a/source4/heimdal/lib/roken/resolve.c
+++ b/source4/heimdal/lib/roken/resolve.c
@@ -48,8 +48,6 @@
#include <assert.h>
-RCSID("$Id$");
-
#ifdef _AIX /* AIX have broken res_nsearch() in 5.1 (5.0 also ?) */
#undef HAVE_RES_NSEARCH
#endif
diff --git a/source4/heimdal/lib/roken/rkpty.c b/source4/heimdal/lib/roken/rkpty.c
index bff632f0f1..2776c1318b 100644
--- a/source4/heimdal/lib/roken/rkpty.c
+++ b/source4/heimdal/lib/roken/rkpty.c
@@ -120,7 +120,7 @@ open_pty(void)
strlcpy(line, ptsname(master), sizeof(line));
slave = open(line, O_RDWR);
if (slave < 0)
- errx(1, "failed to open slave when using %s", q);
+ errx(1, "failed to open slave when using %s", *q);
ioctl(slave, I_PUSH, "ptem");
ioctl(slave, I_PUSH, "ldterm");
diff --git a/source4/heimdal/lib/roken/roken-common.h b/source4/heimdal/lib/roken/roken-common.h
index 1713b6609e..ea7dcaade0 100644
--- a/source4/heimdal/lib/roken/roken-common.h
+++ b/source4/heimdal/lib/roken/roken-common.h
@@ -447,6 +447,8 @@ rk_cloexec(int);
void ROKEN_LIB_FUNCTION
rk_cloexec_file(FILE *);
+int ROKEN_LIB_FUNCTION
+ct_memcmp(const void *, const void *, size_t);
ROKEN_CPP_END
diff --git a/source4/heimdal/lib/roken/roken.h.in b/source4/heimdal/lib/roken/roken.h.in
index 3fce136875..2bd471736c 100644
--- a/source4/heimdal/lib/roken/roken.h.in
+++ b/source4/heimdal/lib/roken/roken.h.in
@@ -32,8 +32,6 @@
* SUCH DAMAGE.
*/
-/* $Id$ */
-
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
@@ -114,7 +112,7 @@ struct sockaddr_dl;
#ifdef HAVE_TERMIOS_H
#include <termios.h>
#endif
-#if defined(HAVE_SYS_IOCTL_H) && SunOS != 40
+#ifdef HAVE_SYS_IOCTL_H
#include <sys/ioctl.h>
#endif
#ifdef TIME_WITH_SYS_TIME
@@ -126,6 +124,10 @@ struct sockaddr_dl;
#include <time.h>
#endif
+#ifdef HAVE_WS2TCPIP_H
+#include <ws2tcpip.h>
+#endif
+
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
@@ -309,7 +311,7 @@ char * ROKEN_LIB_FUNCTION strerror(int);
#define hstrerror rk_hstrerror
#endif
/* This causes a fatal error under Psoriasis */
-#if !(defined(SunOS) && (SunOS >= 50))
+#ifndef SunOS
const char * ROKEN_LIB_FUNCTION hstrerror(int);
#endif
#endif
@@ -337,7 +339,7 @@ int ROKEN_LIB_FUNCTION
inet_pton(int, const char *, void *);
#endif
-#if !defined(HAVE_GETCWD)
+#ifndef HAVE_GETCWD
#define getcwd rk_getcwd
char* ROKEN_LIB_FUNCTION getcwd(char *, size_t);
#endif
@@ -470,10 +472,14 @@ unsigned short ROKEN_LIB_FUNCTION bswap16(unsigned short);
#define LOCK_UN 8 /* Unlock */
#endif
-#define flock rk_flock
-int flock(int fd, int operation);
+#define flock(_x,_y) rk_flock(_x,_y)
+int rk_flock(int fd, int operation);
#endif /* HAVE_FLOCK */
+#ifdef SunOS
+#define dirfd(x) ((x)->dd_fd)
+#endif
+
time_t ROKEN_LIB_FUNCTION tm2time (struct tm, int);
int ROKEN_LIB_FUNCTION unix_verify_user(char *, char *);
@@ -677,26 +683,12 @@ char * ROKEN_LIB_FUNCTION estrdup (const char *);
* kludges and such
*/
-#if 1
int ROKEN_LIB_FUNCTION
roken_gethostby_setup(const char*, const char*);
struct hostent* ROKEN_LIB_FUNCTION
roken_gethostbyname(const char*);
struct hostent* ROKEN_LIB_FUNCTION
roken_gethostbyaddr(const void*, size_t, int);
-#else
-#ifdef GETHOSTBYNAME_PROTO_COMPATIBLE
-#define roken_gethostbyname(x) gethostbyname(x)
-#else
-#define roken_gethostbyname(x) gethostbyname((char *)x)
-#endif
-
-#ifdef GETHOSTBYADDR_PROTO_COMPATIBLE
-#define roken_gethostbyaddr(a, l, t) gethostbyaddr(a, l, t)
-#else
-#define roken_gethostbyaddr(a, l, t) gethostbyaddr((char *)a, l, t)
-#endif
-#endif
#ifdef GETSERVBYNAME_PROTO_COMPATIBLE
#define roken_getservbyname(x,y) getservbyname(x,y)
diff --git a/source4/heimdal/lib/roken/vis.c b/source4/heimdal/lib/roken/vis.c
index c8d19a4455..155b148e86 100644
--- a/source4/heimdal/lib/roken/vis.c
+++ b/source4/heimdal/lib/roken/vis.c
@@ -223,9 +223,9 @@ do_svis(char *dst, int c, int flag, int nextc, const char *extra)
}
if (isextra || ((c & 0177) == ' ') || (flag & VIS_OCTAL)) {
*dst++ = '\\';
- *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + '0';
- *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + '0';
- *dst++ = (c & 07) + '0';
+ *dst++ = (u_char)(((unsigned int)(u_char)c >> 6) & 03) + '0';
+ *dst++ = (u_char)(((unsigned int)(u_char)c >> 3) & 07) + '0';
+ *dst++ = (u_char)( c & 07) + '0';
} else {
if ((flag & VIS_NOSLASH) == 0) *dst++ = '\\';
if (c & 0200) {