|
|
f33542 |
--- test/request.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ test/request.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -902,8 +902,6 @@
|
|
|
f33542 |
ONREQ(ne_request_dispatch(req));
|
|
|
f33542 |
|
|
|
f33542 |
while ((cursor = ne_response_header_iterate(req, cursor, &name, &value))) {
|
|
|
f33542 |
- n = -1;
|
|
|
f33542 |
-
|
|
|
f33542 |
ONV(strncmp(name, "x-", 2) || strncmp(value, "Y-", 2)
|
|
|
f33542 |
|| strcmp(name + 2, value + 2)
|
|
|
f33542 |
|| (n = atoi(name + 2)) >= MANY_HEADERS
|
|
|
f33542 |
@@ -2358,6 +2356,21 @@
|
|
|
f33542 |
return await_server();
|
|
|
f33542 |
}
|
|
|
f33542 |
|
|
|
f33542 |
+static int safe_flags(void)
|
|
|
f33542 |
+{
|
|
|
f33542 |
+ ne_session *sess = ne_session_create("http", "localhost", 80);
|
|
|
f33542 |
+ ne_request *req = ne_request_create(sess, "GET", "/");
|
|
|
f33542 |
+
|
|
|
f33542 |
+ ne_set_request_flag(req, NE_REQFLAG_LAST, 0xAAAAAAAA);
|
|
|
f33542 |
+
|
|
|
f33542 |
+ ONN("flags array bound check failed", ne_get_session(req) != sess);
|
|
|
f33542 |
+
|
|
|
f33542 |
+ ne_request_destroy(req);
|
|
|
f33542 |
+ ne_session_destroy(sess);
|
|
|
f33542 |
+
|
|
|
f33542 |
+ return OK;
|
|
|
f33542 |
+}
|
|
|
f33542 |
+
|
|
|
f33542 |
/* TODO: test that ne_set_notifier(, NULL, NULL) DTRT too. */
|
|
|
f33542 |
|
|
|
f33542 |
ne_test tests[] = {
|
|
|
f33542 |
@@ -2451,5 +2464,6 @@
|
|
|
f33542 |
T(socks_fail),
|
|
|
f33542 |
T(fail_lookup),
|
|
|
f33542 |
T(fail_double_lookup),
|
|
|
f33542 |
+ T(safe_flags),
|
|
|
f33542 |
T(NULL)
|
|
|
f33542 |
};
|
|
|
f33542 |
--- test/lock.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ test/lock.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -73,11 +73,13 @@
|
|
|
f33542 |
const char *token_href)
|
|
|
f33542 |
{
|
|
|
f33542 |
static char buf[BUFSIZ];
|
|
|
f33542 |
- sprintf(buf,
|
|
|
f33542 |
- "\n"
|
|
|
f33542 |
- "<D:prop xmlns:D=\"DAV:\">"
|
|
|
f33542 |
- "<D:lockdiscovery>%s</D:lockdiscovery></D:prop>\n",
|
|
|
f33542 |
- activelock(scope, depth, owner, timeout, token_href));
|
|
|
f33542 |
+
|
|
|
f33542 |
+ ne_snprintf(buf, sizeof buf,
|
|
|
f33542 |
+ "\n"
|
|
|
f33542 |
+ "<D:prop xmlns:D=\"DAV:\">"
|
|
|
f33542 |
+ "<D:lockdiscovery>%s</D:lockdiscovery></D:prop>\n",
|
|
|
f33542 |
+ activelock(scope, depth, owner, timeout, token_href));
|
|
|
f33542 |
+
|
|
|
f33542 |
return buf;
|
|
|
f33542 |
}
|
|
|
f33542 |
|
|
|
f33542 |
--- test/string-tests.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ test/string-tests.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -320,7 +320,7 @@
|
|
|
f33542 |
{
|
|
|
f33542 |
char expect[200], actual[200];
|
|
|
f33542 |
|
|
|
f33542 |
- strncpy(expect, strerror(ENOENT), sizeof(expect));
|
|
|
f33542 |
+ strncpy(expect, strerror(ENOENT), sizeof(expect)-1);
|
|
|
f33542 |
ONN("ne_strerror did not return passed-in buffer",
|
|
|
f33542 |
ne_strerror(ENOENT, actual, sizeof(actual)) != actual);
|
|
|
f33542 |
|
|
|
f33542 |
--- test/util-tests.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ test/util-tests.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -203,18 +203,24 @@
|
|
|
f33542 |
return OK;
|
|
|
f33542 |
}
|
|
|
f33542 |
|
|
|
f33542 |
-/* trigger segfaults in ne_rfc1036_parse() in <=0.24.5. */
|
|
|
f33542 |
-static int regress_dates(void)
|
|
|
f33542 |
+#define BAD_DATE(format, result) \
|
|
|
f33542 |
+ ONN(format " date parse must fail", result != -1)
|
|
|
f33542 |
+
|
|
|
f33542 |
+/* Test for bad dates; trigger segfaults in ne_rfc1036_parse() in
|
|
|
f33542 |
+ * <=0.24.5. */
|
|
|
f33542 |
+static int bad_dates(void)
|
|
|
f33542 |
{
|
|
|
f33542 |
static const char *dates[] = {
|
|
|
f33542 |
- "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
|
|
|
f33542 |
+ "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
|
|
|
f33542 |
+ "Friday, 08-Jun-01",
|
|
|
f33542 |
};
|
|
|
f33542 |
size_t n;
|
|
|
f33542 |
|
|
|
f33542 |
for (n = 0; n < sizeof(dates)/sizeof(dates[0]); n++) {
|
|
|
f33542 |
- ne_rfc1036_parse(dates[n]);
|
|
|
f33542 |
- ne_iso8601_parse(dates[n]);
|
|
|
f33542 |
- ne_rfc1123_parse(dates[n]);
|
|
|
f33542 |
+ BAD_DATE("rfc1036", ne_rfc1036_parse(dates[n]));
|
|
|
f33542 |
+ BAD_DATE("iso8601", ne_iso8601_parse(dates[n]));
|
|
|
f33542 |
+ BAD_DATE("rfc1123", ne_rfc1123_parse(dates[n]));
|
|
|
f33542 |
+ BAD_DATE("asctime", ne_asctime_parse(dates[n]));
|
|
|
f33542 |
}
|
|
|
f33542 |
|
|
|
f33542 |
return OK;
|
|
|
f33542 |
@@ -303,7 +309,7 @@
|
|
|
f33542 |
T(md5),
|
|
|
f33542 |
T(md5_alignment),
|
|
|
f33542 |
T(parse_dates),
|
|
|
f33542 |
- T(regress_dates),
|
|
|
f33542 |
+ T(bad_dates),
|
|
|
f33542 |
T(versioning),
|
|
|
f33542 |
T(version_string),
|
|
|
f33542 |
T(support),
|
|
|
f33542 |
--- src/ne_dates.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ src/ne_dates.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -171,11 +171,12 @@
|
|
|
f33542 |
int n;
|
|
|
f33542 |
time_t result;
|
|
|
f33542 |
|
|
|
f33542 |
-/* it goes: Sun, 06 Nov 1994 08:49:37 GMT */
|
|
|
f33542 |
- n = sscanf(date, RFC1123_FORMAT,
|
|
|
f33542 |
- wkday, &gmt.tm_mday, mon, &gmt.tm_year, &gmt.tm_hour,
|
|
|
f33542 |
- &gmt.tm_min, &gmt.tm_sec);
|
|
|
f33542 |
- /* Is it portable to check n==7 here? */
|
|
|
f33542 |
+ /* it goes: Sun, 06 Nov 1994 08:49:37 GMT */
|
|
|
f33542 |
+ if (sscanf(date, RFC1123_FORMAT,
|
|
|
f33542 |
+ wkday, &gmt.tm_mday, mon, &gmt.tm_year, &gmt.tm_hour,
|
|
|
f33542 |
+ &gmt.tm_min, &gmt.tm_sec) != 7)
|
|
|
f33542 |
+ return (time_t) -1;
|
|
|
f33542 |
+
|
|
|
f33542 |
gmt.tm_year -= 1900;
|
|
|
f33542 |
for (n=0; n<12; n++)
|
|
|
f33542 |
if (strcmp(mon, short_months[n]) == 0)
|
|
|
f33542 |
@@ -204,7 +205,6 @@
|
|
|
f33542 |
return (time_t)-1;
|
|
|
f33542 |
}
|
|
|
f33542 |
|
|
|
f33542 |
- /* portable to check n here? */
|
|
|
f33542 |
for (n=0; n<12; n++)
|
|
|
f33542 |
if (strcmp(mon, short_months[n]) == 0)
|
|
|
f33542 |
break;
|
|
|
f33542 |
@@ -232,11 +232,12 @@
|
|
|
f33542 |
char wkday[4], mon[4];
|
|
|
f33542 |
time_t result;
|
|
|
f33542 |
|
|
|
f33542 |
- n = sscanf(date, ASCTIME_FORMAT,
|
|
|
f33542 |
- wkday, mon, &gmt.tm_mday,
|
|
|
f33542 |
- &gmt.tm_hour, &gmt.tm_min, &gmt.tm_sec,
|
|
|
f33542 |
- &gmt.tm_year);
|
|
|
f33542 |
- /* portable to check n here? */
|
|
|
f33542 |
+ if (sscanf(date, ASCTIME_FORMAT,
|
|
|
f33542 |
+ wkday, mon, &gmt.tm_mday,
|
|
|
f33542 |
+ &gmt.tm_hour, &gmt.tm_min, &gmt.tm_sec,
|
|
|
f33542 |
+ &gmt.tm_year) != 7)
|
|
|
f33542 |
+ return (time_t)-1;
|
|
|
f33542 |
+
|
|
|
f33542 |
for (n=0; n<12; n++)
|
|
|
f33542 |
if (strcmp(mon, short_months[n]) == 0)
|
|
|
f33542 |
break;
|
|
|
f33542 |
--- src/ne_locks.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ src/ne_locks.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -32,6 +32,7 @@
|
|
|
f33542 |
#ifdef HAVE_LIMITS_H
|
|
|
f33542 |
#include <limits.h>
|
|
|
f33542 |
#endif
|
|
|
f33542 |
+#include <assert.h>
|
|
|
f33542 |
|
|
|
f33542 |
#include <ctype.h> /* for isdigit() */
|
|
|
f33542 |
|
|
|
f33542 |
@@ -332,6 +333,9 @@
|
|
|
f33542 |
for (item = store->locks; item != NULL; item = item->next)
|
|
|
f33542 |
if (item->lock == lock)
|
|
|
f33542 |
break;
|
|
|
f33542 |
+
|
|
|
f33542 |
+ /* API condition that lock is present in the store. */
|
|
|
f33542 |
+ assert(item);
|
|
|
f33542 |
|
|
|
f33542 |
if (item->prev != NULL) {
|
|
|
f33542 |
item->prev->next = item->next;
|
|
|
f33542 |
--- src/ne_session.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ src/ne_session.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -569,7 +569,8 @@
|
|
|
f33542 |
};
|
|
|
f33542 |
int n, flag = 0;
|
|
|
f33542 |
|
|
|
f33542 |
- strcpy(sess->error, _("Server certificate verification failed: "));
|
|
|
f33542 |
+ ne_strnzcpy(sess->error, _("Server certificate verification failed: "),
|
|
|
f33542 |
+ sizeof sess->error);
|
|
|
f33542 |
|
|
|
f33542 |
for (n = 0; reasons[n].bit; n++) {
|
|
|
f33542 |
if (failures & reasons[n].bit) {
|
|
|
f33542 |
--- src/ne_xml.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ src/ne_xml.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -576,7 +576,7 @@
|
|
|
f33542 |
if (p->bom_pos == 0) {
|
|
|
f33542 |
p->bom_pos = 3; /* no BOM */
|
|
|
f33542 |
} else if (p->bom_pos > 0 && p->bom_pos < 3) {
|
|
|
f33542 |
- strcpy(p->error, _("Invalid Byte Order Mark"));
|
|
|
f33542 |
+ ne_strnzcpy(p->error, _("Invalid Byte Order Mark"), sizeof p->error);
|
|
|
f33542 |
return p->failure = 1;
|
|
|
f33542 |
}
|
|
|
f33542 |
}
|
|
|
f33542 |
--- src/ne_request.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ src/ne_request.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -329,7 +329,7 @@
|
|
|
f33542 |
/* errno was set */
|
|
|
f33542 |
ne_strerror(errno, err, sizeof err);
|
|
|
f33542 |
} else {
|
|
|
f33542 |
- strcpy(err, _("offset invalid"));
|
|
|
f33542 |
+ ne_strnzcpy(err, _("offset invalid"), sizeof err);
|
|
|
f33542 |
}
|
|
|
f33542 |
ne_snprintf(offstr, sizeof offstr, "%" FMT_NE_OFF_T,
|
|
|
f33542 |
req->body.file.offset);
|
|
|
f33542 |
@@ -585,7 +585,7 @@
|
|
|
f33542 |
|
|
|
f33542 |
void ne_set_request_flag(ne_request *req, ne_request_flag flag, int value)
|
|
|
f33542 |
{
|
|
|
f33542 |
- if (flag < (ne_request_flag)NE_SESSFLAG_LAST) {
|
|
|
f33542 |
+ if (flag < (ne_request_flag)NE_REQFLAG_LAST) {
|
|
|
f33542 |
req->flags[flag] = value;
|
|
|
f33542 |
}
|
|
|
f33542 |
}
|
|
|
f33542 |
--- src/ne_socket.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ src/ne_socket.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -27,7 +27,7 @@
|
|
|
f33542 |
#include "config.h"
|
|
|
f33542 |
|
|
|
f33542 |
#include <sys/types.h>
|
|
|
f33542 |
-#ifdef HAVE_SYS_UIO_h
|
|
|
f33542 |
+#ifdef HAVE_SYS_UIO_H
|
|
|
f33542 |
#include <sys/uio.h> /* writev(2) */
|
|
|
f33542 |
#endif
|
|
|
f33542 |
#ifdef HAVE_SYS_TIME_H
|
|
|
f33542 |
--- src/ne_openssl.c (.../tags/0.30.2) (revision 2045)
|
|
|
f33542 |
+++ src/ne_openssl.c (.../branches/0.30.x) (revision 2045)
|
|
|
f33542 |
@@ -1130,7 +1130,10 @@
|
|
|
f33542 |
return 0;
|
|
|
f33542 |
}
|
|
|
f33542 |
|
|
|
f33542 |
-#ifdef NE_HAVE_TS_SSL
|
|
|
f33542 |
+#if defined(NE_HAVE_TS_SSL) && OPENSSL_VERSION_NUMBER < 0x10101000L
|
|
|
f33542 |
+/* For OpenSSL 1.1.1 locking callbacks are no longer need at all. */
|
|
|
f33542 |
+#define WITH_OPENSSL_LOCKING (1)
|
|
|
f33542 |
+
|
|
|
f33542 |
/* Implementation of locking callbacks to make OpenSSL thread-safe.
|
|
|
f33542 |
* If the OpenSSL API was better designed, this wouldn't be necessary.
|
|
|
f33542 |
* In OpenSSL releases without CRYPTO_set_idptr_callback, it's not
|
|
|
f33542 |
@@ -1184,8 +1187,6 @@
|
|
|
f33542 |
}
|
|
|
f33542 |
}
|
|
|
f33542 |
|
|
|
f33542 |
-#endif
|
|
|
f33542 |
-
|
|
|
f33542 |
/* ID_CALLBACK_IS_{NEON,OTHER} evaluate as true if the currently
|
|
|
f33542 |
* registered OpenSSL ID callback is the neon function (_NEON), or has
|
|
|
f33542 |
* been overwritten by some other app (_OTHER). */
|
|
|
f33542 |
@@ -1196,6 +1197,8 @@
|
|
|
f33542 |
#define ID_CALLBACK_IS_OTHER (CRYPTO_get_id_callback() != NULL)
|
|
|
f33542 |
#define ID_CALLBACK_IS_NEON (CRYPTO_get_id_callback() == thread_id_neon)
|
|
|
f33542 |
#endif
|
|
|
f33542 |
+
|
|
|
f33542 |
+#endif /* NE_HAVE_TS_SSL && OPENSSL_VERSION_NUMBER < 1.1.1 */
|
|
|
f33542 |
|
|
|
f33542 |
int ne__ssl_init(void)
|
|
|
f33542 |
{
|
|
|
f33542 |
@@ -1205,7 +1208,7 @@
|
|
|
f33542 |
SSL_library_init();
|
|
|
f33542 |
OpenSSL_add_all_algorithms();
|
|
|
f33542 |
|
|
|
f33542 |
-#ifdef NE_HAVE_TS_SSL
|
|
|
f33542 |
+#ifdef WITH_OPENSSL_LOCKING
|
|
|
f33542 |
/* If some other library has already come along and set up the
|
|
|
f33542 |
* thread-safety callbacks, then it must be presumed that the
|
|
|
f33542 |
* other library will have a longer lifetime in the process than
|
|
|
f33542 |
@@ -1252,7 +1255,7 @@
|
|
|
f33542 |
/* Cannot call ERR_free_strings() etc here in case any other code
|
|
|
f33542 |
* in the process using OpenSSL. */
|
|
|
f33542 |
|
|
|
f33542 |
-#ifdef NE_HAVE_TS_SSL
|
|
|
f33542 |
+#ifdef WITH_OPENSSL_LOCKING
|
|
|
f33542 |
/* Only unregister the callbacks if some *other* library has not
|
|
|
f33542 |
* come along in the mean-time and trampled over the callbacks
|
|
|
f33542 |
* installed by neon. */
|