-5b91f58f350c92fb9eacd1ebac558381b0b8deac
+42f9c644cf00be752f09d85a9664bf2e3502101c
#define SHA256_Init hc_SHA256_Init
#define SHA256_Update hc_SHA256_Update
#define SHA256_Final hc_SHA256_Final
+#define SHA384_Init hc_SHA384_Init
+#define SHA384_Update hc_SHA384_Update
+#define SHA384_Final hc_SHA384_Final
+#define SHA512_Init hc_SHA512_Init
+#define SHA512_Update hc_SHA512_Update
+#define SHA512_Final hc_SHA512_Final
/*
* SHA-1
krb5_config_binding **parent,
const char **err_message);
-static krb5_config_section *
-get_entry(krb5_config_section **parent, const char *name, int type)
+krb5_config_section *
+_krb5_config_get_entry(krb5_config_section **parent, const char *name, int type)
{
krb5_config_section **q;
return KRB5_CONFIG_BADFORMAT;
}
*p1 = '\0';
- tmp = get_entry(parent, p + 1, krb5_config_list);
+ tmp = _krb5_config_get_entry(parent, p + 1, krb5_config_list);
if(tmp == NULL) {
*err_message = "out of memory";
return KRB5_CONFIG_BADFORMAT;
parse_list(struct fileptr *f, unsigned *lineno, krb5_config_binding **parent,
const char **err_message)
{
- char buf[BUFSIZ];
+ char buf[KRB5_BUFSIZ];
krb5_error_code ret;
krb5_config_binding *b = NULL;
unsigned beg_lineno = *lineno;
++p;
*p2 = '\0';
if (*p == '{') {
- tmp = get_entry(parent, p1, krb5_config_list);
+ tmp = _krb5_config_get_entry(parent, p1, krb5_config_list);
if (tmp == NULL) {
*err_message = "out of memory";
return KRB5_CONFIG_BADFORMAT;
}
ret = parse_list (f, lineno, &tmp->u.list, err_message);
} else {
- tmp = get_entry(parent, p1, krb5_config_string);
+ tmp = _krb5_config_get_entry(parent, p1, krb5_config_string);
if (tmp == NULL) {
*err_message = "out of memory";
return KRB5_CONFIG_BADFORMAT;
return;
if (CFGetTypeID(value) == CFStringGetTypeID()) {
- tmp = get_entry(parent, k, krb5_config_string);
+ tmp = _krb5_config_get_entry(parent, k, krb5_config_string);
tmp->u.string = cfstring2cstring(value);
} else if (CFGetTypeID(value) == CFDictionaryGetTypeID()) {
- tmp = get_entry(parent, k, krb5_config_list);
+ tmp = _krb5_config_get_entry(parent, k, krb5_config_list);
CFDictionaryApplyFunction(value, convert_content, &tmp->u.list);
} else {
/* log */
{
krb5_config_section *s = NULL;
krb5_config_binding *b = NULL;
- char buf[BUFSIZ];
+ char buf[KRB5_BUFSIZ];
krb5_error_code ret;
while (config_fgets(buf, sizeof(buf), f) != NULL) {
return ret;
}
+static char *
+next_component_string(char * begin, char * delims, char **state)
+{
+ char * end;
+
+ if (begin == NULL)
+ begin = *state;
+
+ if (*begin == '\0')
+ return NULL;
+
+ end = begin;
+ while (*end == '"') {
+ char * t;
+ while ((t = strchr(end + 1, '"')) != NULL && *(t - 1) == '\\') {
+ --t;
+ memmove(t, t + 1, strlen(t));
+ end = t;
+ }
+
+ if (t)
+ end = ++t;
+ else
+ end += strlen(end);
+ }
+
+ if (*end != '\0') {
+ size_t pos;
+
+ pos = strcspn(end, delims);
+ end = end + pos;
+ }
+
+ if (*end != '\0') {
+ *end = '\0';
+ *state = end + 1;
+ if (*begin == '"' && *(end - 1) == '"' && begin + 1 < end) {
+ begin++; *(end - 1) = '\0';
+ }
+ return begin;
+ }
+
+ *state = end;
+ if (*begin == '"' && *(end - 1) == '"' && begin + 1 < end) {
+ begin++; *(end - 1) = '\0';
+ }
+ return begin;
+}
+
/**
* Get a list of configuration strings, free the result with
* krb5_config_free_strings().
char *s;
if(tmp == NULL)
goto cleanup;
- s = strtok_r(tmp, " \t", &pos);
+ s = next_component_string(tmp, " \t", &pos);
while(s){
char **tmp2 = realloc(strings, (nstr + 1) * sizeof(*strings));
if(tmp2 == NULL)
nstr++;
if(strings[nstr-1] == NULL)
goto cleanup;
- s = strtok_r(NULL, " \t", &pos);
+ s = next_component_string(NULL, " \t", &pos);
}
free(tmp);
}
*/
KRB5_DEPRECATED
-krb5_error_code KRB5_LIB_FUNCTION
+KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
krb5_config_parse_string_multi(krb5_context context,
const char *string,
krb5_config_section **res)
ROKEN_LIB_FUNCTION struct tm * ROKEN_LIB_CALL
localtime_r(const time_t *timer, struct tm *result)
{
+#ifdef _MSC_VER
+
+ return (localtime_s(result, timer) == 0)? result : NULL;
+
+#else
struct tm *tm;
tm = localtime((time_t *)timer);
return NULL;
*result = *tm;
return result;
+#endif
}
#endif
#endif /* !_WIN32 */
+/* Minimize conflict with WinNT.h */
+#ifdef SLIST_ENTRY
+#undef SLIST_ENTRY
+#endif
+
#ifndef PATH_MAX
#define PATH_MAX MAX_PATH
#endif
#define AI_NUMERICHOST 0x04
#endif
+#ifndef AI_NUMERICSERV
+#define AI_NUMERICSERV 0x08
+#endif
+
/* flags for getnameinfo() */
#ifndef NI_DGRAM
ROKEN_LIB_FUNCTION int ROKEN_LIB_CALL
ct_memcmp(const void *, const void *, size_t);
+void ROKEN_LIB_FUNCTION
+rk_random_init(void);
+
ROKEN_CPP_END
#endif /* __ROKEN_COMMON_H__ */
#include <time.h>
#endif
-#ifdef HAVE_WS2TCPIP_H
-#include <ws2tcpip.h>
-#endif
-
#ifdef HAVE_PATHS_H
#include <paths.h>
#endif
rk_qsort(void *, size_t, size_t, int (*)(const void *, const void *));
#endif
+#if defined(HAVE_ARC4RANDOM)
+#define rk_random() arc4random()
+#elif defined(HAVE_RANDOM)
+#define rk_random() random()
+#else
+#define rk_random() rand()
+#endif
+
+
#if defined(__linux__) && defined(SOCK_CLOEXEC) && !defined(SOCKET_WRAPPER_REPLACE) && !defined(__SOCKET_WRAPPER_H__)
#undef socket
#define socket(_fam,_type,_prot) rk_socket(_fam,_type,_prot)
return sizeof(struct in6_addr);
#endif
default :
- errx (1, "unknown address family %d", sa->sa_family);
- UNREACHABLE(return 0);
+ return 0;
}
}
case AF_INET6 :
return sizeof(struct sockaddr_in6);
#endif
- default :
- errx (1, "unknown address family %d", sa->sa_family);
- UNREACHABLE(return 0);
+ default:
+ return 0;
}
}
return rk_UNCONST(&sin6->sin6_addr);
}
#endif
- default :
- errx (1, "unknown address family %d", sa->sa_family);
- UNREACHABLE(return NULL);
+ default:
+ return NULL;
}
}
}
#endif
default :
- errx (1, "unknown address family %d", sa->sa_family);
- UNREACHABLE(return 0);
+ return 0;
}
}
#if defined(IP_PORTRANGE)
if (af == AF_INET) {
int on = restr ? IP_PORTRANGE_HIGH : IP_PORTRANGE_DEFAULT;
- if (setsockopt (sock, IPPROTO_IP, IP_PORTRANGE, &on,
- sizeof(on)) < 0)
- warn ("setsockopt IP_PORTRANGE (ignored)");
+ setsockopt (sock, IPPROTO_IP, IP_PORTRANGE, &on, sizeof(on));
}
#endif
#if defined(IPV6_PORTRANGE)
if (af == AF_INET6) {
- int on = restr ? IPV6_PORTRANGE_HIGH :
- IPV6_PORTRANGE_DEFAULT;
- if (setsockopt (sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on,
- sizeof(on)) < 0)
- warn ("setsockopt IPV6_PORTRANGE (ignored)");
+ int on = restr ? IPV6_PORTRANGE_HIGH : IPV6_PORTRANGE_DEFAULT;
+ setsockopt (sock, IPPROTO_IPV6, IPV6_PORTRANGE, &on, sizeof(on));
}
#endif
}
{
#if defined(SO_DEBUG) && defined(HAVE_SETSOCKOPT)
int on = 1;
-
- if (setsockopt (sock, SOL_SOCKET, SO_DEBUG, (void *) &on, sizeof (on)) < 0)
- warn ("setsockopt SO_DEBUG (ignored)");
+ setsockopt (sock, SOL_SOCKET, SO_DEBUG, (void *) &on, sizeof (on));
#endif
}
socket_set_tos (rk_socket_t sock, int tos)
{
#if defined(IP_TOS) && defined(HAVE_SETSOCKOPT)
- if (setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof (int)) < 0)
- if (errno != EINVAL)
- warn ("setsockopt TOS (ignored)");
+ setsockopt (sock, IPPROTO_IP, IP_TOS, (void *) &tos, sizeof(int));
#endif
}
socket_set_reuseaddr (rk_socket_t sock, int val)
{
#if defined(SO_REUSEADDR) && defined(HAVE_SETSOCKOPT)
- if(setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val,
- sizeof(val)) < 0)
- err (1, "setsockopt SO_REUSEADDR");
+ setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&val, sizeof(val));
#endif
}