mirror of
https://github.com/freebsd/freebsd-src.git
synced 2026-10-31 04:45:39 +01:00
Compare commits
100
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
671fb7df97 | ||
|
|
792e18eda4 | ||
|
|
4372a8abb9 | ||
|
|
ee2ac57fcd | ||
|
|
512b217070 | ||
|
|
67e9d9f440 | ||
|
|
17fd01f05d | ||
|
|
17ed644781 | ||
|
|
60c3a17946 | ||
|
|
3b2158e5ad | ||
|
|
62bbb5c601 | ||
|
|
8802b72b4e | ||
|
|
fe73edb427 | ||
|
|
33aff35778 | ||
|
|
7c79f14cff | ||
|
|
5b4e1ec6a8 | ||
|
|
f49310563e | ||
|
|
613505b093 | ||
|
|
190ecec782 | ||
|
|
ff7167d87b | ||
|
|
0b2bc2f1d2 | ||
|
|
89f3b03b54 | ||
|
|
80f08e175b | ||
|
|
1e9a4fa85c | ||
|
|
7109dada7c | ||
|
|
0d3ec54958 | ||
|
|
11637f5724 | ||
|
|
08f8bf6588 | ||
|
|
29479789b4 | ||
|
|
7d55fc9230 | ||
|
|
827f2d8e5c | ||
|
|
0be478f83f | ||
|
|
9fec72cb49 | ||
|
|
e20fd6cb7b | ||
|
|
6b44e7fe78 | ||
|
|
45bb561ccc | ||
|
|
f411688074 | ||
|
|
abefffa73c | ||
|
|
51b0565b0b | ||
|
|
396875fe9e | ||
|
|
f1b919399c | ||
|
|
8b3112669f | ||
|
|
e78b4e5988 | ||
|
|
640c199940 | ||
|
|
526e8ae9ee | ||
|
|
ef384e0d40 | ||
|
|
368f1ba3f9 | ||
|
|
b3bc68d93c | ||
|
|
304fd4ea7a | ||
|
|
c8fc89515f | ||
|
|
b46f188dc4 | ||
|
|
30c09759e3 | ||
|
|
702af97a48 | ||
|
|
ac40671ce0 | ||
|
|
e38b3d3a99 | ||
|
|
bc37050e42 | ||
|
|
584adb92ca | ||
|
|
2c8efb0f82 | ||
|
|
badb1d48f4 | ||
|
|
3e1942ddba | ||
|
|
a3e93a9010 | ||
|
|
e6e75a30c1 | ||
|
|
dcbfdf410f | ||
|
|
506794cf4c | ||
|
|
ccf787d164 | ||
|
|
661075afaf | ||
|
|
92e01550f4 | ||
|
|
71c931d251 | ||
|
|
b5e2ba4f5a | ||
|
|
3e4c1aa52a | ||
|
|
7573d5ed7d | ||
|
|
e2d4a6a8f3 | ||
|
|
2e1a0dde62 | ||
|
|
c1037f3947 | ||
|
|
ed982599f0 | ||
|
|
37f9784baa | ||
|
|
5d8732b259 | ||
|
|
e4a4adc85c | ||
|
|
b8112e2e89 | ||
|
|
daa9993e80 | ||
|
|
be17245afc | ||
|
|
c0e055fae0 | ||
|
|
a34455d414 | ||
|
|
7eb5f0fd3c | ||
|
|
02c0075216 | ||
|
|
5a26bb96ef | ||
|
|
34608b523e | ||
|
|
b794f476db | ||
|
|
99062cdd66 | ||
|
|
a47474b311 | ||
|
|
f172e9db6f | ||
|
|
c3b7936afe | ||
|
|
f4ef939946 | ||
|
|
dc45a739f1 | ||
|
|
12c212870e | ||
|
|
9423e30951 | ||
|
|
6b814739f1 | ||
|
|
82d4204a10 | ||
|
|
bfea20cf8b | ||
|
|
555a66dde3 |
No files matched your search
@@ -209,7 +209,8 @@ SUB_MAKE= `test -x ${MYMAKE} && echo ${MYMAKE} || echo ${MAKE}` \
|
||||
SUB_MAKE= ${MAKE} -m ${.CURDIR}/share/mk
|
||||
.endif
|
||||
|
||||
_MAKE= PATH=${PATH} ${SUB_MAKE} -f Makefile.inc1 TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
|
||||
_MAKE= PATH=${PATH} MAKE_CMD=${MAKE} ${SUB_MAKE} -f Makefile.inc1 \
|
||||
TARGET=${_TARGET} TARGET_ARCH=${_TARGET_ARCH}
|
||||
|
||||
# Only allow meta mode for the whitelisted targets. See META_TGT_WHITELIST
|
||||
# above.
|
||||
|
||||
+3
-13
@@ -1579,10 +1579,6 @@ _groff= gnu/usr.bin/groff \
|
||||
_vtfontcvt= usr.bin/vtfontcvt
|
||||
.endif
|
||||
|
||||
.if ${BOOTSTRAPPING} < 900002
|
||||
_sed= usr.bin/sed
|
||||
.endif
|
||||
|
||||
.if ${BOOTSTRAPPING} < 1000033
|
||||
_libopenbsd= lib/libopenbsd
|
||||
_m4= usr.bin/m4
|
||||
@@ -1621,10 +1617,6 @@ _crunchide= usr.sbin/crunch/crunchide
|
||||
_crunchgen= usr.sbin/crunch/crunchgen
|
||||
.endif
|
||||
|
||||
.if ${BOOTSTRAPPING} >= 900040 && ${BOOTSTRAPPING} < 900041
|
||||
_awk= usr.bin/awk
|
||||
.endif
|
||||
|
||||
# r296926 -P keymap search path, MFC to stable/10 in r298297
|
||||
.if ${BOOTSTRAPPING} < 1003501 || \
|
||||
(${BOOTSTRAPPING} >= 1100000 && ${BOOTSTRAPPING} < 1100103)
|
||||
@@ -1692,7 +1684,6 @@ bootstrap-tools: .PHONY
|
||||
${_gperf} \
|
||||
${_groff} \
|
||||
${_dtc} \
|
||||
${_awk} \
|
||||
${_cat} \
|
||||
${_dd} \
|
||||
${_kbdcontrol} \
|
||||
@@ -1700,7 +1691,6 @@ bootstrap-tools: .PHONY
|
||||
${_libopenbsd} \
|
||||
${_makewhatis} \
|
||||
usr.bin/rpcgen \
|
||||
${_sed} \
|
||||
${_yacc} \
|
||||
${_m4} \
|
||||
${_lex} \
|
||||
@@ -2372,11 +2362,11 @@ check-old-dirs: .PHONY
|
||||
done
|
||||
|
||||
delete-old: delete-old-files delete-old-dirs .PHONY
|
||||
@echo "To remove old libraries run '${MAKE} delete-old-libs'."
|
||||
@echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
|
||||
|
||||
check-old: check-old-files check-old-libs check-old-dirs .PHONY
|
||||
@echo "To remove old files and directories run '${MAKE} delete-old'."
|
||||
@echo "To remove old libraries run '${MAKE} delete-old-libs'."
|
||||
@echo "To remove old files and directories run '${MAKE_CMD} delete-old'."
|
||||
@echo "To remove old libraries run '${MAKE_CMD} delete-old-libs'."
|
||||
|
||||
.endif
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@ from older versions of FreeBSD, try WITHOUT_CLANG and WITH_GCC to bootstrap to
|
||||
the tip of head, and then rebuild without this option. The bootstrap process
|
||||
from older version of current across the gcc/clang cutover is a bit fragile.
|
||||
|
||||
20160928:
|
||||
11.0-RELEASE.
|
||||
|
||||
20160622:
|
||||
The libc stub for the pipe(2) system call has been replaced with
|
||||
a wrapper that calls the pipe2(2) system call and the pipe(2)
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
v0.10
|
||||
v0.11
|
||||
@@ -142,7 +142,7 @@ main(int argc, char **argv)
|
||||
logfail(EX_CANTCREAT, "cannot build mbox path for `%s/%s'", _PATH_MAILDIR, user);
|
||||
}
|
||||
|
||||
f = open(fn, O_RDONLY|O_CREAT, 0600);
|
||||
f = open(fn, O_RDONLY|O_CREAT|O_NOFOLLOW, 0600);
|
||||
if (f < 0)
|
||||
logfail(EX_NOINPUT, "cannt open mbox `%s'", fn);
|
||||
|
||||
|
||||
+2
-2
@@ -321,7 +321,7 @@ deliver(struct qitem *it)
|
||||
snprintf(errmsg, sizeof(errmsg), "unknown bounce reason");
|
||||
|
||||
retry:
|
||||
syslog(LOG_INFO, "trying delivery");
|
||||
syslog(LOG_INFO, "<%s> trying delivery", it->addr);
|
||||
|
||||
if (it->remote)
|
||||
error = deliver_remote(it);
|
||||
@@ -331,7 +331,7 @@ retry:
|
||||
switch (error) {
|
||||
case 0:
|
||||
delqueue(it);
|
||||
syslog(LOG_INFO, "delivery successful");
|
||||
syslog(LOG_INFO, "<%s> delivery successful", it->addr);
|
||||
exit(EX_OK);
|
||||
|
||||
case 1:
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@
|
||||
#define VERSION "DragonFly Mail Agent " DMA_VERSION
|
||||
|
||||
#define BUF_SIZE 2048
|
||||
#define ERRMSG_SIZE 200
|
||||
#define ERRMSG_SIZE 1024
|
||||
#define USERNAME_SIZE 50
|
||||
#define MIN_RETRY 300 /* 5 minutes */
|
||||
#define MAX_RETRY (3*60*60) /* retry at least every 3 hours */
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
*/
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/param.h>
|
||||
#include <netinet/in.h>
|
||||
#include <arpa/inet.h>
|
||||
#include <arpa/nameser.h>
|
||||
|
||||
+1
-1
@@ -196,7 +196,7 @@ retry:
|
||||
goto out;
|
||||
}
|
||||
|
||||
error = snprintf(line, sizeof(line), "%sFrom %s\t%s", newline, sender, ctime(&now));
|
||||
error = snprintf(line, sizeof(line), "%sFrom %s %s", newline, sender, ctime(&now));
|
||||
if (error < 0 || (size_t)error >= sizeof(line)) {
|
||||
syslog(LOG_NOTICE, "local delivery deferred: can not write header: %m");
|
||||
goto out;
|
||||
|
||||
+6
-3
@@ -372,11 +372,13 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
|
||||
host->host, host->addr, c, neterr); \
|
||||
snprintf(errmsg, sizeof(errmsg), "%s [%s] did not like our %s:\n%s", \
|
||||
host->host, host->addr, c, neterr); \
|
||||
return (-1); \
|
||||
error = -1; \
|
||||
goto out; \
|
||||
} else if (res != exp) { \
|
||||
syslog(LOG_NOTICE, "remote delivery deferred: %s [%s] failed after %s: %s", \
|
||||
host->host, host->addr, c, neterr); \
|
||||
return (1); \
|
||||
error = 1; \
|
||||
goto out; \
|
||||
}
|
||||
|
||||
/* Check first reply from remote host */
|
||||
@@ -426,7 +428,8 @@ deliver_to_host(struct qitem *it, struct mx_hostentry *host)
|
||||
syslog(LOG_ERR, "remote delivery failed:"
|
||||
" SMTP login failed: %m");
|
||||
snprintf(errmsg, sizeof(errmsg), "SMTP login to %s failed", host->host);
|
||||
return (-1);
|
||||
error = -1;
|
||||
goto out;
|
||||
}
|
||||
/* SMTP login is not available, so try without */
|
||||
else if (error > 0) {
|
||||
|
||||
@@ -83,7 +83,7 @@ DEFINE_TEST(test_version)
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
|
||||
@@ -63,6 +63,7 @@ static const struct option {
|
||||
} cpio_longopts[] = {
|
||||
{ "b64encode", 0, OPTION_B64ENCODE },
|
||||
{ "create", 0, 'o' },
|
||||
{ "dereference", 0, 'L' },
|
||||
{ "dot", 0, 'V' },
|
||||
{ "extract", 0, 'i' },
|
||||
{ "file", 1, 'F' },
|
||||
|
||||
@@ -75,7 +75,7 @@ verify(const char *p, size_t s)
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
|
||||
@@ -655,7 +655,7 @@ add_pattern_from_file(struct archive_match *a, struct match_list *mlist,
|
||||
}
|
||||
}
|
||||
|
||||
/* If something error happend, report it immediately. */
|
||||
/* If an error occurred, report it immediately. */
|
||||
if (r < ARCHIVE_OK) {
|
||||
archive_copy_error(&(a->archive), ar);
|
||||
archive_read_free(ar);
|
||||
|
||||
@@ -19,7 +19,7 @@ If you need the compatibility with original PPMd var.H, you can use external Ran
|
||||
#define PPMD7_MAX_ORDER 64
|
||||
|
||||
#define PPMD7_MIN_MEM_SIZE (1 << 11)
|
||||
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFF - 12 * 3)
|
||||
#define PPMD7_MAX_MEM_SIZE (0xFFFFFFFFu - 12 * 3)
|
||||
|
||||
struct CPpmd7_Context_;
|
||||
|
||||
|
||||
@@ -125,7 +125,7 @@ void
|
||||
__archive_read_reset_passphrase(struct archive_read *a)
|
||||
{
|
||||
|
||||
a->passphrases.candiate = -1;
|
||||
a->passphrases.candidate = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -137,31 +137,31 @@ __archive_read_next_passphrase(struct archive_read *a)
|
||||
struct archive_read_passphrase *p;
|
||||
const char *passphrase;
|
||||
|
||||
if (a->passphrases.candiate < 0) {
|
||||
if (a->passphrases.candidate < 0) {
|
||||
/* Count out how many passphrases we have. */
|
||||
int cnt = 0;
|
||||
|
||||
for (p = a->passphrases.first; p != NULL; p = p->next)
|
||||
cnt++;
|
||||
a->passphrases.candiate = cnt;
|
||||
a->passphrases.candidate = cnt;
|
||||
p = a->passphrases.first;
|
||||
} else if (a->passphrases.candiate > 1) {
|
||||
} else if (a->passphrases.candidate > 1) {
|
||||
/* Rotate a passphrase list. */
|
||||
a->passphrases.candiate--;
|
||||
a->passphrases.candidate--;
|
||||
p = remove_passphrases_from_head(a);
|
||||
add_passphrase_to_tail(a, p);
|
||||
/* Pick a new passphrase candiate up. */
|
||||
/* Pick a new passphrase candidate up. */
|
||||
p = a->passphrases.first;
|
||||
} else if (a->passphrases.candiate == 1) {
|
||||
/* This case is that all cadiates failed to decryption. */
|
||||
a->passphrases.candiate = 0;
|
||||
} else if (a->passphrases.candidate == 1) {
|
||||
/* This case is that all candidates failed to decrypt. */
|
||||
a->passphrases.candidate = 0;
|
||||
if (a->passphrases.first->next != NULL) {
|
||||
/* Rotate a passphrase list. */
|
||||
p = remove_passphrases_from_head(a);
|
||||
add_passphrase_to_tail(a, p);
|
||||
}
|
||||
p = NULL;
|
||||
} else /* There is no passphrase candaite. */
|
||||
} else /* There is no passphrase candidate. */
|
||||
p = NULL;
|
||||
|
||||
if (p != NULL)
|
||||
@@ -177,7 +177,7 @@ __archive_read_next_passphrase(struct archive_read *a)
|
||||
if (p == NULL)
|
||||
return (NULL);
|
||||
insert_passphrase_to_head(a, p);
|
||||
a->passphrases.candiate = 1;
|
||||
a->passphrases.candidate = 1;
|
||||
}
|
||||
} else
|
||||
passphrase = NULL;
|
||||
|
||||
@@ -641,13 +641,16 @@ translate_acl(struct archive_read_disk *a,
|
||||
* Libarchive stores "flag" (NFSv4 inheritance bits)
|
||||
* in the ae_perm bitmap.
|
||||
*/
|
||||
acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (acl_get_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit))
|
||||
ae_perm |= acl_inherit_map[i].archive_inherit;
|
||||
|
||||
}
|
||||
// XXX acl_get_flagset_np on FreeBSD returns EINVAL for
|
||||
// non-NFSv4 ACLs
|
||||
r = acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
if (r == 0) {
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (acl_get_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit))
|
||||
ae_perm |= acl_inherit_map[i].archive_inherit;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
acl_get_permset(acl_entry, &acl_permset);
|
||||
|
||||
@@ -938,7 +938,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
|
||||
r = archive_match_path_excluded(a->matching, entry);
|
||||
if (r < 0) {
|
||||
archive_set_error(&(a->archive), errno,
|
||||
"Faild : %s", archive_error_string(a->matching));
|
||||
"Failed : %s", archive_error_string(a->matching));
|
||||
return (r);
|
||||
}
|
||||
if (r) {
|
||||
@@ -1041,7 +1041,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
|
||||
r = archive_match_time_excluded(a->matching, entry);
|
||||
if (r < 0) {
|
||||
archive_set_error(&(a->archive), errno,
|
||||
"Faild : %s", archive_error_string(a->matching));
|
||||
"Failed : %s", archive_error_string(a->matching));
|
||||
return (r);
|
||||
}
|
||||
if (r) {
|
||||
@@ -1067,7 +1067,7 @@ next_entry(struct archive_read_disk *a, struct tree *t,
|
||||
r = archive_match_owner_excluded(a->matching, entry);
|
||||
if (r < 0) {
|
||||
archive_set_error(&(a->archive), errno,
|
||||
"Faild : %s", archive_error_string(a->matching));
|
||||
"Failed : %s", archive_error_string(a->matching));
|
||||
return (r);
|
||||
}
|
||||
if (r) {
|
||||
|
||||
@@ -221,7 +221,7 @@ struct archive_read {
|
||||
struct {
|
||||
struct archive_read_passphrase *first;
|
||||
struct archive_read_passphrase **last;
|
||||
int candiate;
|
||||
int candidate;
|
||||
archive_passphrase_callback *callback;
|
||||
void *client_data;
|
||||
} passphrases;
|
||||
|
||||
@@ -595,7 +595,7 @@ lz4_filter_read_data_block(struct archive_read_filter *self, const void **p)
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Check if an error happend in decompression process. */
|
||||
/* Check if an error occurred in the decompression process. */
|
||||
if (uncompressed_size < 0) {
|
||||
archive_set_error(&(self->archive->archive),
|
||||
ARCHIVE_ERRNO_MISC, "lz4 decompression failed");
|
||||
|
||||
@@ -1715,8 +1715,11 @@ lha_crc16(uint16_t crc, const void *pp, size_t len)
|
||||
#undef bswap16
|
||||
#if defined(_MSC_VER) && _MSC_VER >= 1400 /* Visual Studio */
|
||||
# define bswap16(x) _byteswap_ushort(x)
|
||||
#elif (defined(__GNUC__) && __GNUC__ >= 4 && __GNUC_MINOR__ >= 8) \
|
||||
|| defined(__clang__)
|
||||
#elif defined(__GNUC__) && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 8) || __GNUC__ > 4)
|
||||
/* GCC 4.8 and later has __builtin_bswap16() */
|
||||
# define bswap16(x) __builtin_bswap16(x)
|
||||
#elif defined(__clang__)
|
||||
/* All clang versions have __builtin_bswap16() */
|
||||
# define bswap16(x) __builtin_bswap16(x)
|
||||
#else
|
||||
# define bswap16(x) ((((x) >> 8) & 0xff) | ((x) << 8))
|
||||
|
||||
@@ -1128,8 +1128,15 @@ header_common(struct archive_read *a, struct tar *tar,
|
||||
if (tar->entry_bytes_remaining < 0) {
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry has negative size?");
|
||||
err = ARCHIVE_WARN;
|
||||
"Tar entry has negative size");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
if (tar->entry_bytes_remaining == INT64_MAX) {
|
||||
/* Note: tar_atol returns INT64_MAX on overflow */
|
||||
tar->entry_bytes_remaining = 0;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_MISC,
|
||||
"Tar entry size overflow");
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
tar->realsize = tar->entry_bytes_remaining;
|
||||
archive_entry_set_size(entry, tar->entry_bytes_remaining);
|
||||
|
||||
@@ -318,7 +318,7 @@ start_over:
|
||||
}
|
||||
memcpy(w->pool.str, fnam.str, fnam.len);
|
||||
w->pool.str[fnam.len] = '\0';
|
||||
/* let noone else know about the pool, it's a secret, shhh */
|
||||
/* let no one else know about the pool, it's a secret, shhh */
|
||||
fnam.str = w->pool.str;
|
||||
|
||||
/* snarf mtime or deduce from rtime
|
||||
|
||||
@@ -418,18 +418,30 @@ zip_time(const char *p)
|
||||
* id1+size1+data1 + id2+size2+data2 ...
|
||||
* triplets. id and size are 2 bytes each.
|
||||
*/
|
||||
static void
|
||||
process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
static int
|
||||
process_extra(struct archive_read *a, const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
{
|
||||
unsigned offset = 0;
|
||||
|
||||
while (offset < extra_length - 4) {
|
||||
if (extra_length == 0) {
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
if (extra_length < 4) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Too-small extra data: Need at least 4 bytes, but only found %d bytes", (int)extra_length);
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
while (offset <= extra_length - 4) {
|
||||
unsigned short headerid = archive_le16dec(p + offset);
|
||||
unsigned short datasize = archive_le16dec(p + offset + 2);
|
||||
|
||||
offset += 4;
|
||||
if (offset + datasize > extra_length) {
|
||||
break;
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Extra data overflow: Need %d bytes but only found %d bytes",
|
||||
(int)datasize, (int)(extra_length - offset));
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
fprintf(stderr, "Header id 0x%04x, length %d\n",
|
||||
@@ -715,13 +727,13 @@ process_extra(const char *p, size_t extra_length, struct zip_entry* zip_entry)
|
||||
}
|
||||
offset += datasize;
|
||||
}
|
||||
#ifdef DEBUG
|
||||
if (offset != extra_length)
|
||||
{
|
||||
fprintf(stderr,
|
||||
"Extra data field contents do not match reported size!\n");
|
||||
if (offset != extra_length) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Malformed extra data: Consumed %d bytes of %d bytes",
|
||||
(int)offset, (int)extra_length);
|
||||
return ARCHIVE_FAILED;
|
||||
}
|
||||
#endif
|
||||
return ARCHIVE_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -840,7 +852,9 @@ zip_read_local_file_header(struct archive_read *a, struct archive_entry *entry,
|
||||
return (ARCHIVE_FATAL);
|
||||
}
|
||||
|
||||
process_extra(h, extra_length, zip_entry);
|
||||
if (ARCHIVE_OK != process_extra(a, h, extra_length, zip_entry)) {
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
__archive_read_consume(a, extra_length);
|
||||
|
||||
/* Work around a bug in Info-Zip: When reading from a pipe, it
|
||||
@@ -1293,7 +1307,7 @@ zip_read_data_deflate(struct archive_read *a, const void **buff,
|
||||
&& bytes_avail > zip->entry_bytes_remaining) {
|
||||
bytes_avail = (ssize_t)zip->entry_bytes_remaining;
|
||||
}
|
||||
if (bytes_avail <= 0) {
|
||||
if (bytes_avail < 0) {
|
||||
archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT,
|
||||
"Truncated ZIP file body");
|
||||
return (ARCHIVE_FATAL);
|
||||
@@ -2691,7 +2705,9 @@ slurp_central_directory(struct archive_read *a, struct zip *zip)
|
||||
"Truncated ZIP file header");
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
process_extra(p + filename_length, extra_length, zip_entry);
|
||||
if (ARCHIVE_OK != process_extra(a, p + filename_length, extra_length, zip_entry)) {
|
||||
return ARCHIVE_FATAL;
|
||||
}
|
||||
|
||||
/*
|
||||
* Mac resource fork files are stored under the
|
||||
|
||||
@@ -580,7 +580,7 @@ void
|
||||
__archive_ensure_cloexec_flag(int fd)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
(void)fd; /* UNSED */
|
||||
(void)fd; /* UNUSED */
|
||||
#else
|
||||
int flags;
|
||||
|
||||
|
||||
@@ -138,6 +138,7 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
acl_permset_t acl_permset;
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
acl_flagset_t acl_flagset;
|
||||
int r;
|
||||
#endif
|
||||
int ret;
|
||||
int ae_type, ae_permset, ae_tag, ae_id;
|
||||
@@ -223,12 +224,16 @@ set_acl(struct archive *a, int fd, const char *name,
|
||||
}
|
||||
|
||||
#ifdef ACL_TYPE_NFS4
|
||||
acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
acl_clear_flags_np(acl_flagset);
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (ae_permset & acl_inherit_map[i].archive_inherit)
|
||||
acl_add_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit);
|
||||
// XXX acl_get_flagset_np on FreeBSD returns EINVAL for
|
||||
// non-NFSv4 ACLs
|
||||
r = acl_get_flagset_np(acl_entry, &acl_flagset);
|
||||
if (r == 0) {
|
||||
acl_clear_flags_np(acl_flagset);
|
||||
for (i = 0; i < (int)(sizeof(acl_inherit_map) / sizeof(acl_inherit_map[0])); ++i) {
|
||||
if (ae_permset & acl_inherit_map[i].archive_inherit)
|
||||
acl_add_flag_np(acl_flagset,
|
||||
acl_inherit_map[i].platform_inherit);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -1796,7 +1796,7 @@ edit_deep_directories(struct archive_write_disk *a)
|
||||
char *tail = a->name;
|
||||
|
||||
/* If path is short, avoid the open() below. */
|
||||
if (strlen(tail) <= PATH_MAX)
|
||||
if (strlen(tail) < PATH_MAX)
|
||||
return;
|
||||
|
||||
/* Try to record our starting dir. */
|
||||
@@ -1806,7 +1806,7 @@ edit_deep_directories(struct archive_write_disk *a)
|
||||
return;
|
||||
|
||||
/* As long as the path is too long... */
|
||||
while (strlen(tail) > PATH_MAX) {
|
||||
while (strlen(tail) >= PATH_MAX) {
|
||||
/* Locate a dir prefix shorter than PATH_MAX. */
|
||||
tail += PATH_MAX - 8;
|
||||
while (tail > a->name && *tail != '/')
|
||||
@@ -2401,8 +2401,18 @@ check_symlinks(struct archive_write_disk *a)
|
||||
r = lstat(a->name, &st);
|
||||
if (r != 0) {
|
||||
/* We've hit a dir that doesn't exist; stop now. */
|
||||
if (errno == ENOENT)
|
||||
if (errno == ENOENT) {
|
||||
break;
|
||||
} else {
|
||||
/* Note: This effectively disables deep directory
|
||||
* support when security checks are enabled.
|
||||
* Otherwise, very long pathnames that trigger
|
||||
* an error here could evade the sandbox.
|
||||
* TODO: We could do better, but it would probably
|
||||
* require merging the symlink checks with the
|
||||
* deep-directory editing. */
|
||||
return (ARCHIVE_FAILED);
|
||||
}
|
||||
} else if (S_ISLNK(st.st_mode)) {
|
||||
if (c == '\0') {
|
||||
/*
|
||||
|
||||
@@ -436,7 +436,7 @@ struct iso_option {
|
||||
* Type : string
|
||||
* Default: Auto detect
|
||||
* : We check a size of boot image;
|
||||
* : If ths size is just 1.22M/1.44M/2.88M,
|
||||
* : If the size is just 1.22M/1.44M/2.88M,
|
||||
* : we assume boot_type is 'fd';
|
||||
* : otherwise boot_type is 'no-emulation'.
|
||||
* COMPAT :
|
||||
|
||||
@@ -307,7 +307,7 @@ archive_write_ustar_header(struct archive_write *a, struct archive_entry *entry)
|
||||
* case getting WCS failed. On POSIX, this is a
|
||||
* normal operation.
|
||||
*/
|
||||
if (p != NULL && p[strlen(p) - 1] != '/') {
|
||||
if (p != NULL && p[0] != '\0' && p[strlen(p) - 1] != '/') {
|
||||
struct archive_string as;
|
||||
|
||||
archive_string_init(&as);
|
||||
|
||||
@@ -1440,6 +1440,31 @@ assertion_file_size(const char *file, int line, const char *pathname, long size)
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Verify mode of 'pathname'. */
|
||||
int
|
||||
assertion_file_mode(const char *file, int line, const char *pathname, int expected_mode)
|
||||
{
|
||||
int mode;
|
||||
int r;
|
||||
|
||||
assertion_count(file, line);
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
failure_start(file, line, "assertFileMode not yet implemented for Windows");
|
||||
#else
|
||||
{
|
||||
struct stat st;
|
||||
r = lstat(pathname, &st);
|
||||
mode = (int)(st.st_mode & 0777);
|
||||
}
|
||||
if (r == 0 && mode == expected_mode)
|
||||
return (1);
|
||||
failure_start(file, line, "File %s has mode %o, expected %o",
|
||||
pathname, mode, expected_mode);
|
||||
#endif
|
||||
failure_finish(NULL);
|
||||
return (0);
|
||||
}
|
||||
|
||||
/* Assert that 'pathname' is a dir. If mode >= 0, verify that too. */
|
||||
int
|
||||
assertion_is_dir(const char *file, int line, const char *pathname, int mode)
|
||||
|
||||
@@ -182,6 +182,8 @@
|
||||
assertion_file_nlinks(__FILE__, __LINE__, pathname, nlinks)
|
||||
#define assertFileSize(pathname, size) \
|
||||
assertion_file_size(__FILE__, __LINE__, pathname, size)
|
||||
#define assertFileMode(pathname, mode) \
|
||||
assertion_file_mode(__FILE__, __LINE__, pathname, mode)
|
||||
#define assertTextFileContents(text, pathname) \
|
||||
assertion_text_file_contents(__FILE__, __LINE__, text, pathname)
|
||||
#define assertFileContainsLinesAnyOrder(pathname, lines) \
|
||||
@@ -246,6 +248,7 @@ int assertion_file_mtime_recent(const char *, int, const char *);
|
||||
int assertion_file_nlinks(const char *, int, const char *, int);
|
||||
int assertion_file_not_exists(const char *, int, const char *);
|
||||
int assertion_file_size(const char *, int, const char *, long);
|
||||
int assertion_file_mode(const char *, int, const char *, int);
|
||||
int assertion_is_dir(const char *, int, const char *, int);
|
||||
int assertion_is_hardlink(const char *, int, const char *, const char *);
|
||||
int assertion_is_not_hardlink(const char *, int, const char *, const char *);
|
||||
|
||||
@@ -800,8 +800,8 @@ DEFINE_TEST(test_archive_string_conversion)
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
|
||||
assert((fp = fopen(testdata, "w")) != NULL);
|
||||
while ((size = archive_read_data(a, buff, 512)) > 0)
|
||||
fwrite(buff, 1, size, fp);
|
||||
fclose(fp);
|
||||
assertEqualInt(size, fwrite(buff, 1, size, fp));
|
||||
assertEqualInt(0, fclose(fp));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_free(a));
|
||||
|
||||
test_archive_string_normalization_nfc(testdata);
|
||||
|
||||
@@ -110,13 +110,17 @@ test_fuzz(const struct files *filesets)
|
||||
for (i = 0; filesets[n].names[i] != NULL; ++i)
|
||||
{
|
||||
tmp = slurpfile(&size, filesets[n].names[i]);
|
||||
rawimage = (char *)realloc(rawimage, oldsize + size);
|
||||
char *newraw = (char *)realloc(rawimage, oldsize + size);
|
||||
if (!assert(newraw != NULL))
|
||||
{
|
||||
free(rawimage);
|
||||
continue;
|
||||
}
|
||||
rawimage = newraw;
|
||||
memcpy(rawimage + oldsize, tmp, size);
|
||||
oldsize += size;
|
||||
size = oldsize;
|
||||
free(tmp);
|
||||
if (!assert(rawimage != NULL))
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (size == 0)
|
||||
|
||||
@@ -3603,7 +3603,7 @@ DEFINE_TEST(test_read_format_rar_multivolume_uncompressed_files)
|
||||
assertEqualIntA(a, 0, archive_read_data(a, buff, sizeof(buff)));
|
||||
|
||||
/*
|
||||
* Eigth header.
|
||||
* Eighth header.
|
||||
*/
|
||||
assertA(0 == archive_read_next_header(a, &ae));
|
||||
assertEqualString("testdir/testsymlink6", archive_entry_pathname(ae));
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*-
|
||||
* Copyright (c) 2016 Tim Kientzle
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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 "test.h"
|
||||
__FBSDID("$FreeBSD");
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
|
||||
/*
|
||||
* Github Issue 748 reported problems with end-of-entry handling
|
||||
* with highly-compressible data. This resulted in the end of the
|
||||
* data being truncated (extracted as zero bytes).
|
||||
*/
|
||||
|
||||
/*
|
||||
* Extract the specific test archive that was used to diagnose
|
||||
* Issue 748:
|
||||
*/
|
||||
DEFINE_TEST(test_read_format_zip_high_compression)
|
||||
{
|
||||
const char *refname = "test_read_format_zip_high_compression.zip";
|
||||
char *p;
|
||||
size_t archive_size;
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
|
||||
const void *pv;
|
||||
size_t s;
|
||||
int64_t o;
|
||||
|
||||
extract_reference_file(refname);
|
||||
p = slurpfile(&archive_size, refname);
|
||||
|
||||
assert((a = archive_read_new()) != NULL);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_zip(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, read_open_memory_seek(a, p, archive_size, 16 * 1024));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(262144, s);
|
||||
assertEqualInt(0, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(160, s);
|
||||
assertEqualInt(262144, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_free(a));
|
||||
free(p);
|
||||
}
|
||||
|
||||
/*
|
||||
* Synthesize a lot of varying inputs that are highly compressible.
|
||||
*/
|
||||
DEFINE_TEST(test_read_format_zip_high_compression2)
|
||||
{
|
||||
const size_t body_size = 1024 * 1024;
|
||||
const size_t buff_size = 2 * 1024 * 1024;
|
||||
char *body, *body_read, *buff;
|
||||
int n;
|
||||
|
||||
assert((body = malloc(body_size)) != NULL);
|
||||
assert((body_read = malloc(body_size)) != NULL);
|
||||
assert((buff = malloc(buff_size)) != NULL);
|
||||
|
||||
/* Highly-compressible data: all bytes 255, except for a
|
||||
* single 1 byte.
|
||||
* The body is always 256k + 6 bytes long (the internal deflation
|
||||
* buffer is exactly 256k).
|
||||
*/
|
||||
|
||||
for(n = 1024; n < (int)body_size; n += 1024) {
|
||||
struct archive *a;
|
||||
struct archive_entry *entry;
|
||||
size_t used = 0;
|
||||
const void *pv;
|
||||
size_t s;
|
||||
int64_t o;
|
||||
|
||||
memset(body, 255, body_size);
|
||||
body[n] = 1;
|
||||
|
||||
/* Write an archive with a single entry of n bytes. */
|
||||
assert((a = archive_write_new()) != NULL);
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_set_format_zip(a));
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_open_memory(a, buff, buff_size, &used));
|
||||
|
||||
entry = archive_entry_new2(a);
|
||||
archive_entry_set_pathname(entry, "test");
|
||||
archive_entry_set_filetype(entry, AE_IFREG);
|
||||
archive_entry_set_size(entry, 262150);
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_header(a, entry));
|
||||
archive_entry_free(entry);
|
||||
assertEqualInt(262150, archive_write_data(a, body, 262150));
|
||||
assertEqualInt(ARCHIVE_OK, archive_write_free(a));
|
||||
|
||||
/* Read back the entry and verify the contents. */
|
||||
assert((a = archive_read_new()) != NULL);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_format_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_read_support_filter_all(a));
|
||||
assertEqualIntA(a, ARCHIVE_OK, read_open_memory(a, buff, used, 17));
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_next_header(a, &entry));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(262144, s);
|
||||
assertEqualInt(0, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_read_data_block(a, &pv, &s, &o));
|
||||
assertEqualInt(6, s);
|
||||
assertEqualInt(262144, o);
|
||||
|
||||
assertEqualInt(ARCHIVE_EOF, archive_read_data_block(a, &pv, &s, &o));
|
||||
|
||||
assertEqualInt(ARCHIVE_OK, archive_free(a));
|
||||
}
|
||||
|
||||
free(body);
|
||||
free(body_read);
|
||||
free(buff);
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
begin 644 test_read_format_zip_high_compression.zip
|
||||
M4$L#!!0`"``(`*=Y]4@``````````*``!``(`"``8VAA<BYB:6Y55`T`!\L>
|
||||
MD5>>))%7GB215W5X"P`!!/8!```$%````.W=06K#,!`%T&E)P8LL?*2XC@N%
|
||||
M)#5QO>AM<K0<+2=0:!OBP>@9WDJ6!%\6$K/Q6T3LAX]N/GQ'Z9G&KA^*K1'S
|
||||
M.`[GOIM*[TP_Q_>O0[G_:3X.Y\^^V/X2<<GT&IM=$]OK?[71_LJ],3;1+*(T
|
||||
M_U)99\T+````````````````````````````````````````L`:E?]*S#FVT
|
||||
MJY:='SPB>_]DR\X?`("_R:X_U"Y[_:F;;Q``ZN+L!P"H3W;]$_5G`&!9V?</
|
||||
M````X/FRZP_9LO,'@`S9YR^0P_Z'NF7?/P``````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
M````````````````````````````````````````````````````````````
|
||||
MJ%L3VVM-LO,&8/UN4$L'"!<='%^U`0``H``$`%!+`0(4`Q0`"``(`*=Y]4@7
|
||||
M'1Q?M0$``*``!``(`"````````````"D@0````!C:&%R+F)I;E54#0`'RQZ1
|
||||
M5YXDD5>>))%7=7@+``$$]@$```04````4$L%!@`````!``$`5@````L"````
|
||||
!````
|
||||
`
|
||||
end
|
||||
@@ -0,0 +1,95 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007,2016 Tim Kientzle
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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 "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define UMASK 022
|
||||
|
||||
/*
|
||||
* Github Issue #744 describes a bug in the sandboxing code that
|
||||
* causes very long pathnames to not get checked for symlinks.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_write_disk_secure744)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
size_t buff_size = 8192;
|
||||
char *buff = malloc(buff_size);
|
||||
char *p = buff;
|
||||
int n = 0;
|
||||
int t;
|
||||
|
||||
assert(buff != NULL);
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
|
||||
|
||||
while (p + 500 < buff + buff_size) {
|
||||
memset(p, 'x', 100);
|
||||
p += 100;
|
||||
p[0] = '\0';
|
||||
|
||||
buff[0] = ((n / 1000) % 10) + '0';
|
||||
buff[1] = ((n / 100) % 10)+ '0';
|
||||
buff[2] = ((n / 10) % 10)+ '0';
|
||||
buff[3] = ((n / 1) % 10)+ '0';
|
||||
buff[4] = '_';
|
||||
++n;
|
||||
|
||||
/* Create a symlink pointing to the testworkdir */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, buff);
|
||||
archive_entry_set_mode(ae, S_IFREG | 0777);
|
||||
archive_entry_copy_symlink(ae, testworkdir);
|
||||
assertEqualIntA(a, ARCHIVE_OK, archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
*p++ = '/';
|
||||
sprintf(p, "target%d", n);
|
||||
|
||||
/* Try to create a file through the symlink, should fail. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, buff);
|
||||
archive_entry_set_mode(ae, S_IFDIR | 0777);
|
||||
|
||||
t = archive_write_header(a, ae);
|
||||
archive_entry_free(ae);
|
||||
failure("Attempt to create target%d via %d-character symlink should have failed", n, (int)strlen(buff));
|
||||
if(!assertEqualInt(ARCHIVE_FAILED, t)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
archive_free(a);
|
||||
free(buff);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007,2016 Tim Kientzle
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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 "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define UMASK 022
|
||||
|
||||
/*
|
||||
* Github Issue #745 describes a bug in the sandboxing code that
|
||||
* allows one to use a symlink to edit the permissions on a file or
|
||||
* directory outside of the sandbox.
|
||||
*/
|
||||
|
||||
DEFINE_TEST(test_write_disk_secure745)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
|
||||
|
||||
/* The target dir: The one we're going to try to change permission on */
|
||||
assertMakeDir("target", 0700);
|
||||
|
||||
/* The sandbox dir we're going to run inside of. */
|
||||
assertMakeDir("sandbox", 0700);
|
||||
assertChdir("sandbox");
|
||||
|
||||
/* Create a symlink pointing to the target directory */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "sym");
|
||||
archive_entry_set_mode(ae, S_IFREG | 0777);
|
||||
archive_entry_copy_symlink(ae, "../target");
|
||||
assert(0 == archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Try to alter the target dir through the symlink; this should fail. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "sym");
|
||||
archive_entry_set_mode(ae, S_IFDIR | 0777);
|
||||
assert(0 == archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Permission of target dir should not have changed. */
|
||||
assertFileMode("../target", 0700);
|
||||
#endif
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
/*-
|
||||
* Copyright (c) 2003-2007,2016 Tim Kientzle
|
||||
* 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.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``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(S) 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 "test.h"
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#define UMASK 022
|
||||
|
||||
/*
|
||||
* Github Issue #746 describes a problem in which hardlink targets are
|
||||
* not adequately checked and can be used to modify entries outside of
|
||||
* the sandbox.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Verify that ARCHIVE_EXTRACT_SECURE_NODOTDOT disallows '..' in hardlink
|
||||
* targets.
|
||||
*/
|
||||
DEFINE_TEST(test_write_disk_secure746a)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* The target directory we're going to try to affect. */
|
||||
assertMakeDir("target", 0700);
|
||||
assertMakeFile("target/foo", 0700, "unmodified");
|
||||
|
||||
/* The sandbox dir we're going to work within. */
|
||||
assertMakeDir("sandbox", 0700);
|
||||
assertChdir("sandbox");
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_NODOTDOT);
|
||||
|
||||
/* Attempt to hardlink to the target directory. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "bar");
|
||||
archive_entry_set_mode(ae, S_IFREG | 0777);
|
||||
archive_entry_set_size(ae, 8);
|
||||
archive_entry_copy_hardlink(ae, "../target/foo");
|
||||
assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
|
||||
assertEqualInt(ARCHIVE_FAILED, archive_write_data(a, "modified", 8));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Verify that target file contents are unchanged. */
|
||||
assertTextFileContents("unmodified", "../target/foo");
|
||||
#endif
|
||||
}
|
||||
|
||||
/*
|
||||
* Verify that ARCHIVE_EXTRACT_SECURE_NOSYMLINK disallows symlinks in hardlink
|
||||
* targets.
|
||||
*/
|
||||
DEFINE_TEST(test_write_disk_secure746b)
|
||||
{
|
||||
#if defined(_WIN32) && !defined(__CYGWIN__)
|
||||
skipping("archive_write_disk security checks not supported on Windows");
|
||||
#else
|
||||
struct archive *a;
|
||||
struct archive_entry *ae;
|
||||
|
||||
/* Start with a known umask. */
|
||||
assertUmask(UMASK);
|
||||
|
||||
/* The target directory we're going to try to affect. */
|
||||
assertMakeDir("target", 0700);
|
||||
assertMakeFile("target/foo", 0700, "unmodified");
|
||||
|
||||
/* The sandbox dir we're going to work within. */
|
||||
assertMakeDir("sandbox", 0700);
|
||||
assertChdir("sandbox");
|
||||
|
||||
/* Create an archive_write_disk object. */
|
||||
assert((a = archive_write_disk_new()) != NULL);
|
||||
archive_write_disk_set_options(a, ARCHIVE_EXTRACT_SECURE_SYMLINKS);
|
||||
|
||||
/* Create a symlink to the target directory. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "symlink");
|
||||
archive_entry_copy_symlink(ae, "../target");
|
||||
assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Attempt to hardlink to the target directory via the symlink. */
|
||||
assert((ae = archive_entry_new()) != NULL);
|
||||
archive_entry_copy_pathname(ae, "bar");
|
||||
archive_entry_set_mode(ae, S_IFREG | 0777);
|
||||
archive_entry_set_size(ae, 8);
|
||||
archive_entry_copy_hardlink(ae, "symlink/foo");
|
||||
assertEqualInt(ARCHIVE_FAILED, archive_write_header(a, ae));
|
||||
assertEqualInt(ARCHIVE_FAILED, archive_write_data(a, "modified", 8));
|
||||
archive_entry_free(ae);
|
||||
|
||||
/* Verify that target file contents are unchanged. */
|
||||
assertTextFileContents("unmodified", "../target/foo");
|
||||
#endif
|
||||
}
|
||||
@@ -68,6 +68,7 @@ static const struct bsdtar_option {
|
||||
{ "auto-compress", 0, 'a' },
|
||||
{ "b64encode", 0, OPTION_B64ENCODE },
|
||||
{ "block-size", 1, 'b' },
|
||||
{ "blocking-factor", 1, 'b' },
|
||||
{ "bunzip2", 0, 'j' },
|
||||
{ "bzip", 0, 'j' },
|
||||
{ "bzip2", 0, 'j' },
|
||||
|
||||
@@ -88,7 +88,7 @@ DEFINE_TEST(test_version)
|
||||
if (*q == 'a' || *q == 'b' || *q == 'c' || *q == 'd')
|
||||
++q;
|
||||
/* Skip arbitrary third-party version numbers. */
|
||||
while (s > 0 && (*q == ' ' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
while (s > 0 && (*q == ' ' || *q == '-' || *q == '/' || *q == '.' || isalnum(*q))) {
|
||||
++q;
|
||||
--s;
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ safe_fprintf(FILE *f, const char *fmt, ...)
|
||||
}
|
||||
|
||||
/* If our output buffer is full, dump it and keep going. */
|
||||
if (i > (sizeof(outbuff) - 20)) {
|
||||
if (i > (sizeof(outbuff) - 128)) {
|
||||
outbuff[i] = '\0';
|
||||
fprintf(f, "%s", outbuff);
|
||||
i = 0;
|
||||
|
||||
@@ -90,6 +90,7 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
|
||||
{"fixup_arm_movw_lo16", 0, 20, 0},
|
||||
{"fixup_t2_movt_hi16", 0, 20, 0},
|
||||
{"fixup_t2_movw_lo16", 0, 20, 0},
|
||||
{"fixup_arm_mod_imm", 0, 12, 0},
|
||||
};
|
||||
const static MCFixupKindInfo InfosBE[ARM::NumTargetFixupKinds] = {
|
||||
// This table *must* be in the order that the fixup_* kinds are defined in
|
||||
@@ -133,6 +134,7 @@ const MCFixupKindInfo &ARMAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
|
||||
{"fixup_arm_movw_lo16", 12, 20, 0},
|
||||
{"fixup_t2_movt_hi16", 12, 20, 0},
|
||||
{"fixup_t2_movw_lo16", 12, 20, 0},
|
||||
{"fixup_arm_mod_imm", 20, 12, 0},
|
||||
};
|
||||
|
||||
if (Kind < FirstTargetFixupKind)
|
||||
@@ -624,6 +626,13 @@ unsigned ARMAsmBackend::adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
|
||||
|
||||
return Value;
|
||||
}
|
||||
case ARM::fixup_arm_mod_imm:
|
||||
Value = ARM_AM::getSOImmVal(Value);
|
||||
if (Ctx && Value >> 12) {
|
||||
Ctx->reportError(Fixup.getLoc(), "out of range immediate fixup value");
|
||||
return 0;
|
||||
}
|
||||
return Value;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -690,6 +699,7 @@ static unsigned getFixupKindNumBytes(unsigned Kind) {
|
||||
case FK_Data_2:
|
||||
case ARM::fixup_arm_thumb_br:
|
||||
case ARM::fixup_arm_thumb_cb:
|
||||
case ARM::fixup_arm_mod_imm:
|
||||
return 2;
|
||||
|
||||
case ARM::fixup_arm_pcrel_10_unscaled:
|
||||
@@ -766,6 +776,7 @@ static unsigned getFixupKindContainerSizeBytes(unsigned Kind) {
|
||||
case ARM::fixup_arm_movw_lo16:
|
||||
case ARM::fixup_t2_movt_hi16:
|
||||
case ARM::fixup_t2_movw_lo16:
|
||||
case ARM::fixup_arm_mod_imm:
|
||||
// Instruction size is 4 bytes.
|
||||
return 4;
|
||||
}
|
||||
|
||||
@@ -100,6 +100,9 @@ enum Fixups {
|
||||
fixup_t2_movt_hi16, // :upper16:
|
||||
fixup_t2_movw_lo16, // :lower16:
|
||||
|
||||
// fixup_arm_mod_imm - Fixup for mod_imm
|
||||
fixup_arm_mod_imm,
|
||||
|
||||
// Marker
|
||||
LastTargetFixupKind,
|
||||
NumTargetFixupKinds = LastTargetFixupKind - FirstTargetFixupKind
|
||||
|
||||
@@ -312,12 +312,8 @@ public:
|
||||
// Support for fixups (MCFixup)
|
||||
if (MO.isExpr()) {
|
||||
const MCExpr *Expr = MO.getExpr();
|
||||
// In instruction code this value always encoded as lowest 12 bits,
|
||||
// so we don't have to perform any specific adjustments.
|
||||
// Due to requirements of relocatable records we have to use FK_Data_4.
|
||||
// See ARMELFObjectWriter::ExplicitRelSym and
|
||||
// ARMELFObjectWriter::GetRelocTypeInner for more details.
|
||||
MCFixupKind Kind = MCFixupKind(FK_Data_4);
|
||||
// Fixups resolve to plain values that need to be encoded.
|
||||
MCFixupKind Kind = MCFixupKind(ARM::fixup_arm_mod_imm);
|
||||
Fixups.push_back(MCFixup::create(0, Expr, Kind, MI.getLoc()));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -576,7 +576,6 @@ def : Proc<"btver1", [
|
||||
FeaturePRFCHW,
|
||||
FeatureLZCNT,
|
||||
FeaturePOPCNT,
|
||||
FeatureXSAVE,
|
||||
FeatureSlowSHLD,
|
||||
FeatureLAHFSAHF
|
||||
]>;
|
||||
|
||||
@@ -2731,7 +2731,6 @@ bool X86TargetInfo::initFeatureMap(
|
||||
setFeatureEnabledImpl(Features, "prfchw", true);
|
||||
setFeatureEnabledImpl(Features, "cx16", true);
|
||||
setFeatureEnabledImpl(Features, "fxsr", true);
|
||||
setFeatureEnabledImpl(Features, "xsave", true);
|
||||
break;
|
||||
case CK_BDVER4:
|
||||
setFeatureEnabledImpl(Features, "avx2", true);
|
||||
|
||||
@@ -2,6 +2,166 @@
|
||||
OpenSSL CHANGES
|
||||
_______________
|
||||
|
||||
Changes between 1.0.2h and 1.0.2i [22 Sep 2016]
|
||||
|
||||
*) OCSP Status Request extension unbounded memory growth
|
||||
|
||||
A malicious client can send an excessively large OCSP Status Request
|
||||
extension. If that client continually requests renegotiation, sending a
|
||||
large OCSP Status Request extension each time, then there will be unbounded
|
||||
memory growth on the server. This will eventually lead to a Denial Of
|
||||
Service attack through memory exhaustion. Servers with a default
|
||||
configuration are vulnerable even if they do not support OCSP. Builds using
|
||||
the "no-ocsp" build time option are not affected.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6304)
|
||||
[Matt Caswell]
|
||||
|
||||
*) In order to mitigate the SWEET32 attack, the DES ciphers were moved from
|
||||
HIGH to MEDIUM.
|
||||
|
||||
This issue was reported to OpenSSL Karthikeyan Bhargavan and Gaetan
|
||||
Leurent (INRIA)
|
||||
(CVE-2016-2183)
|
||||
[Rich Salz]
|
||||
|
||||
*) OOB write in MDC2_Update()
|
||||
|
||||
An overflow can occur in MDC2_Update() either if called directly or
|
||||
through the EVP_DigestUpdate() function using MDC2. If an attacker
|
||||
is able to supply very large amounts of input data after a previous
|
||||
call to EVP_EncryptUpdate() with a partial block then a length check
|
||||
can overflow resulting in a heap corruption.
|
||||
|
||||
The amount of data needed is comparable to SIZE_MAX which is impractical
|
||||
on most platforms.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6303)
|
||||
[Stephen Henson]
|
||||
|
||||
*) Malformed SHA512 ticket DoS
|
||||
|
||||
If a server uses SHA512 for TLS session ticket HMAC it is vulnerable to a
|
||||
DoS attack where a malformed ticket will result in an OOB read which will
|
||||
ultimately crash.
|
||||
|
||||
The use of SHA512 in TLS session tickets is comparatively rare as it requires
|
||||
a custom server callback and ticket lookup mechanism.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6302)
|
||||
[Stephen Henson]
|
||||
|
||||
*) OOB write in BN_bn2dec()
|
||||
|
||||
The function BN_bn2dec() does not check the return value of BN_div_word().
|
||||
This can cause an OOB write if an application uses this function with an
|
||||
overly large BIGNUM. This could be a problem if an overly large certificate
|
||||
or CRL is printed out from an untrusted source. TLS is not affected because
|
||||
record limits will reject an oversized certificate before it is parsed.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-2182)
|
||||
[Stephen Henson]
|
||||
|
||||
*) OOB read in TS_OBJ_print_bio()
|
||||
|
||||
The function TS_OBJ_print_bio() misuses OBJ_obj2txt(): the return value is
|
||||
the total length the OID text representation would use and not the amount
|
||||
of data written. This will result in OOB reads when large OIDs are
|
||||
presented.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-2180)
|
||||
[Stephen Henson]
|
||||
|
||||
*) Pointer arithmetic undefined behaviour
|
||||
|
||||
Avoid some undefined pointer arithmetic
|
||||
|
||||
A common idiom in the codebase is to check limits in the following manner:
|
||||
"p + len > limit"
|
||||
|
||||
Where "p" points to some malloc'd data of SIZE bytes and
|
||||
limit == p + SIZE
|
||||
|
||||
"len" here could be from some externally supplied data (e.g. from a TLS
|
||||
message).
|
||||
|
||||
The rules of C pointer arithmetic are such that "p + len" is only well
|
||||
defined where len <= SIZE. Therefore the above idiom is actually
|
||||
undefined behaviour.
|
||||
|
||||
For example this could cause problems if some malloc implementation
|
||||
provides an address for "p" such that "p + len" actually overflows for
|
||||
values of len that are too big and therefore p + len < limit.
|
||||
|
||||
This issue was reported to OpenSSL by Guido Vranken
|
||||
(CVE-2016-2177)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Constant time flag not preserved in DSA signing
|
||||
|
||||
Operations in the DSA signing algorithm should run in constant time in
|
||||
order to avoid side channel attacks. A flaw in the OpenSSL DSA
|
||||
implementation means that a non-constant time codepath is followed for
|
||||
certain operations. This has been demonstrated through a cache-timing
|
||||
attack to be sufficient for an attacker to recover the private DSA key.
|
||||
|
||||
This issue was reported by César Pereida (Aalto University), Billy Brumley
|
||||
(Tampere University of Technology), and Yuval Yarom (The University of
|
||||
Adelaide and NICTA).
|
||||
(CVE-2016-2178)
|
||||
[César Pereida]
|
||||
|
||||
*) DTLS buffered message DoS
|
||||
|
||||
In a DTLS connection where handshake messages are delivered out-of-order
|
||||
those messages that OpenSSL is not yet ready to process will be buffered
|
||||
for later use. Under certain circumstances, a flaw in the logic means that
|
||||
those messages do not get removed from the buffer even though the handshake
|
||||
has been completed. An attacker could force up to approx. 15 messages to
|
||||
remain in the buffer when they are no longer required. These messages will
|
||||
be cleared when the DTLS connection is closed. The default maximum size for
|
||||
a message is 100k. Therefore the attacker could force an additional 1500k
|
||||
to be consumed per connection. By opening many simulataneous connections an
|
||||
attacker could cause a DoS attack through memory exhaustion.
|
||||
|
||||
This issue was reported to OpenSSL by Quan Luo.
|
||||
(CVE-2016-2179)
|
||||
[Matt Caswell]
|
||||
|
||||
*) DTLS replay protection DoS
|
||||
|
||||
A flaw in the DTLS replay attack protection mechanism means that records
|
||||
that arrive for future epochs update the replay protection "window" before
|
||||
the MAC for the record has been validated. This could be exploited by an
|
||||
attacker by sending a record for the next epoch (which does not have to
|
||||
decrypt or have a valid MAC), with a very large sequence number. This means
|
||||
that all subsequent legitimate packets are dropped causing a denial of
|
||||
service for a specific DTLS connection.
|
||||
|
||||
This issue was reported to OpenSSL by the OCAP audit team.
|
||||
(CVE-2016-2181)
|
||||
[Matt Caswell]
|
||||
|
||||
*) Certificate message OOB reads
|
||||
|
||||
In OpenSSL 1.0.2 and earlier some missing message length checks can result
|
||||
in OOB reads of up to 2 bytes beyond an allocated buffer. There is a
|
||||
theoretical DoS risk but this has not been observed in practice on common
|
||||
platforms.
|
||||
|
||||
The messages affected are client certificate, client certificate request
|
||||
and server certificate. As a result the attack can only be performed
|
||||
against a client or a server which enables client authentication.
|
||||
|
||||
This issue was reported to OpenSSL by Shi Lei (Gear Team, Qihoo 360 Inc.)
|
||||
(CVE-2016-6306)
|
||||
[Stephen Henson]
|
||||
|
||||
Changes between 1.0.2g and 1.0.2h [3 May 2016]
|
||||
|
||||
*) Prevent padding oracle in AES-NI CBC MAC check
|
||||
|
||||
+65
-28
@@ -1,38 +1,75 @@
|
||||
HOW TO CONTRIBUTE TO OpenSSL
|
||||
----------------------------
|
||||
HOW TO CONTRIBUTE TO PATCHES OpenSSL
|
||||
------------------------------------
|
||||
|
||||
Development is coordinated on the openssl-dev mailing list (see
|
||||
http://www.openssl.org for information on subscribing). If you
|
||||
would like to submit a patch, send it to [email protected] with
|
||||
the string "[PATCH]" in the subject. Please be sure to include a
|
||||
textual explanation of what your patch does.
|
||||
|
||||
You can also make GitHub pull requests. If you do this, please also send
|
||||
mail to [email protected] with a brief description and a link to the PR so
|
||||
that we can more easily keep track of it.
|
||||
(Please visit https://www.openssl.org/community/getting-started.html for
|
||||
other ideas about how to contribute.)
|
||||
|
||||
Development is coordinated on the openssl-dev mailing list (see the
|
||||
above link or https://mta.openssl.org for information on subscribing).
|
||||
If you are unsure as to whether a feature will be useful for the general
|
||||
OpenSSL community please discuss it on the openssl-dev mailing list first.
|
||||
Someone may be already working on the same thing or there may be a good
|
||||
reason as to why that feature isn't implemented.
|
||||
OpenSSL community you might want to discuss it on the openssl-dev mailing
|
||||
list first. Someone may be already working on the same thing or there
|
||||
may be a good reason as to why that feature isn't implemented.
|
||||
|
||||
Patches should be as up to date as possible, preferably relative to the
|
||||
current Git or the last snapshot. They should follow our coding style
|
||||
(see https://www.openssl.org/policies/codingstyle.html) and compile without
|
||||
warnings using the --strict-warnings flag. OpenSSL compiles on many varied
|
||||
platforms: try to ensure you only use portable features.
|
||||
The best way to submit a patch is to make a pull request on GitHub.
|
||||
(It is not necessary to send mail to [email protected] to open a ticket!)
|
||||
If you think the patch could use feedback from the community, please
|
||||
start a thread on openssl-dev.
|
||||
|
||||
Our preferred format for patch files is "git format-patch" output. For example
|
||||
to provide a patch file containing the last commit in your local git repository
|
||||
use the following command:
|
||||
You can also submit patches by sending it as mail to [email protected].
|
||||
Please include the word "PATCH" and an explanation of what the patch
|
||||
does in the subject line. If you do this, our preferred format is "git
|
||||
format-patch" output. For example to provide a patch file containing the
|
||||
last commit in your local git repository use the following command:
|
||||
|
||||
# git format-patch --stdout HEAD^ >mydiffs.patch
|
||||
% git format-patch --stdout HEAD^ >mydiffs.patch
|
||||
|
||||
Another method of creating an acceptable patch file without using git is as
|
||||
follows:
|
||||
|
||||
# cd openssl-work
|
||||
# [your changes]
|
||||
# ./Configure dist; make clean
|
||||
# cd ..
|
||||
# diff -ur openssl-orig openssl-work > mydiffs.patch
|
||||
% cd openssl-work
|
||||
...make your changes...
|
||||
% ./Configure dist; make clean
|
||||
% cd ..
|
||||
% diff -ur openssl-orig openssl-work >mydiffs.patch
|
||||
|
||||
Note that pull requests are generally easier for the team, and community, to
|
||||
work with. Pull requests benefit from all of the standard GitHub features,
|
||||
including code review tools, simpler integration, and CI build support.
|
||||
|
||||
No matter how a patch is submitted, the following items will help make
|
||||
the acceptance and review process faster:
|
||||
|
||||
1. Anything other than trivial contributions will require a contributor
|
||||
licensing agreement, giving us permission to use your code. See
|
||||
https://www.openssl.org/policies/cla.html for details.
|
||||
|
||||
2. All source files should start with the following text (with
|
||||
appropriate comment characters at the start of each line and the
|
||||
year(s) updated):
|
||||
|
||||
Copyright 20xx-20yy The OpenSSL Project Authors. All Rights Reserved.
|
||||
|
||||
Licensed under the OpenSSL license (the "License"). You may not use
|
||||
this file except in compliance with the License. You can obtain a copy
|
||||
in the file LICENSE in the source distribution or at
|
||||
https://www.openssl.org/source/license.html
|
||||
|
||||
3. Patches should be as current as possible. When using GitHub, please
|
||||
expect to have to rebase and update often. Note that we do not accept merge
|
||||
commits. You will be asked to remove them before a patch is considered
|
||||
acceptable.
|
||||
|
||||
4. Patches should follow our coding style (see
|
||||
https://www.openssl.org/policies/codingstyle.html) and compile without
|
||||
warnings. Where gcc or clang is availble you should use the
|
||||
--strict-warnings Configure option. OpenSSL compiles on many varied
|
||||
platforms: try to ensure you only use portable features.
|
||||
|
||||
5. When at all possible, patches should include tests. These can either be
|
||||
added to an existing test, or completely new. Please see test/README
|
||||
for information on the test framework.
|
||||
|
||||
6. New features or changed functionality must include documentation. Please
|
||||
look at the "pod" files in doc/apps, doc/crypto and doc/ssl for examples of
|
||||
our style.
|
||||
@@ -799,7 +799,7 @@ my @experimental = ();
|
||||
|
||||
# This is what $depflags will look like with the above defaults
|
||||
# (we need this to see if we should advise the user to run "make depend"):
|
||||
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST";
|
||||
my $default_depflags = " -DOPENSSL_NO_EC_NISTP_64_GCC_128 -DOPENSSL_NO_GMP -DOPENSSL_NO_JPAKE -DOPENSSL_NO_LIBUNBOUND -DOPENSSL_NO_MD2 -DOPENSSL_NO_RC5 -DOPENSSL_NO_RFC3779 -DOPENSSL_NO_SCTP -DOPENSSL_NO_SSL_TRACE -DOPENSSL_NO_SSL2 -DOPENSSL_NO_STORE -DOPENSSL_NO_UNIT_TEST -DOPENSSL_NO_WEAK_SSL_CIPHERS";
|
||||
|
||||
# Explicit "no-..." options will be collected in %disabled along with the defaults.
|
||||
# To remove something from %disabled, use "enable-foo" (unless it's experimental).
|
||||
@@ -1082,11 +1082,6 @@ if (defined($disabled{"md5"}) || defined($disabled{"sha"})
|
||||
$disabled{"tls1"} = "forced";
|
||||
}
|
||||
|
||||
if (defined($disabled{"tls1"}))
|
||||
{
|
||||
$disabled{"tlsext"} = "forced";
|
||||
}
|
||||
|
||||
if (defined($disabled{"ec"}) || defined($disabled{"dsa"})
|
||||
|| defined($disabled{"dh"}))
|
||||
{
|
||||
@@ -1254,6 +1249,7 @@ my $shared_extension = $fields[$idx_shared_extension];
|
||||
my $ranlib = $ENV{'RANLIB'} || $fields[$idx_ranlib];
|
||||
my $ar = $ENV{'AR'} || "ar";
|
||||
my $arflags = $fields[$idx_arflags];
|
||||
my $windres = $ENV{'RC'} || $ENV{'WINDRES'} || "windres";
|
||||
my $multilib = $fields[$idx_multilib];
|
||||
|
||||
# if $prefix/lib$multilib is not an existing directory, then
|
||||
@@ -1562,8 +1558,15 @@ $cpuid_obj="mem_clr.o" unless ($cpuid_obj =~ /\.o$/);
|
||||
$des_obj=$des_enc unless ($des_obj =~ /\.o$/);
|
||||
$bf_obj=$bf_enc unless ($bf_obj =~ /\.o$/);
|
||||
$cast_obj=$cast_enc unless ($cast_obj =~ /\.o$/);
|
||||
$rc4_obj=$rc4_enc unless ($rc4_obj =~ /\.o$/);
|
||||
$rc5_obj=$rc5_enc unless ($rc5_obj =~ /\.o$/);
|
||||
if ($rc4_obj =~ /\.o$/)
|
||||
{
|
||||
$cflags.=" -DRC4_ASM";
|
||||
}
|
||||
else
|
||||
{
|
||||
$rc4_obj=$rc4_enc;
|
||||
}
|
||||
if ($sha1_obj =~ /\.o$/)
|
||||
{
|
||||
# $sha1_obj=$sha1_enc;
|
||||
@@ -1717,12 +1720,14 @@ while (<IN>)
|
||||
s/^AR=\s*/AR= \$\(CROSS_COMPILE\)/;
|
||||
s/^NM=\s*/NM= \$\(CROSS_COMPILE\)/;
|
||||
s/^RANLIB=\s*/RANLIB= \$\(CROSS_COMPILE\)/;
|
||||
s/^RC=\s*/RC= \$\(CROSS_COMPILE\)/;
|
||||
s/^MAKEDEPPROG=.*$/MAKEDEPPROG= \$\(CROSS_COMPILE\)$cc/ if $cc eq "gcc";
|
||||
}
|
||||
else {
|
||||
s/^CC=.*$/CC= $cc/;
|
||||
s/^AR=\s*ar/AR= $ar/;
|
||||
s/^RANLIB=.*/RANLIB= $ranlib/;
|
||||
s/^RC=.*/RC= $windres/;
|
||||
s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $cc eq "gcc";
|
||||
s/^MAKEDEPPROG=.*$/MAKEDEPPROG= $cc/ if $ecc eq "gcc" || $ecc eq "clang";
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
## Makefile for OpenSSL
|
||||
##
|
||||
|
||||
VERSION=1.0.2h
|
||||
VERSION=1.0.2i
|
||||
MAJOR=1
|
||||
MINOR=0.2
|
||||
SHLIB_VERSION_NUMBER=1.0.0
|
||||
@@ -68,6 +68,7 @@ EXE_EXT=
|
||||
ARFLAGS=
|
||||
AR= ar $(ARFLAGS) r
|
||||
RANLIB= /usr/bin/ranlib
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= /usr/bin/perl
|
||||
TAR= tar
|
||||
@@ -210,6 +211,7 @@ BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
|
||||
CC='$(CC)' CFLAG='$(CFLAG)' \
|
||||
AS='$(CC)' ASFLAG='$(CFLAG) -c' \
|
||||
AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \
|
||||
RC='$(RC)' \
|
||||
CROSS_COMPILE='$(CROSS_COMPILE)' \
|
||||
PERL='$(PERL)' ENGDIRS='$(ENGDIRS)' \
|
||||
SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \
|
||||
@@ -368,6 +370,7 @@ libcrypto.pc: Makefile
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo 'enginesdir=$${libdir}/engines'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libcrypto'; \
|
||||
echo 'Description: OpenSSL cryptography library'; \
|
||||
|
||||
@@ -66,6 +66,7 @@ EXE_EXT=
|
||||
ARFLAGS?= r
|
||||
AR=ar $(ARFLAGS)
|
||||
RANLIB= ranlib
|
||||
RC= windres
|
||||
NM= nm
|
||||
PERL= perl
|
||||
TAR= tar
|
||||
@@ -208,6 +209,7 @@ BUILDENV= LC_ALL=C PLATFORM='$(PLATFORM)' PROCESSOR='$(PROCESSOR)'\
|
||||
CC='$(CC)' CFLAG='$(CFLAG)' \
|
||||
AS='$(CC)' ASFLAG='$(CFLAG) -c' \
|
||||
AR='$(AR)' NM='$(NM)' RANLIB='$(RANLIB)' \
|
||||
RC='$(RC)' \
|
||||
CROSS_COMPILE='$(CROSS_COMPILE)' \
|
||||
PERL='$(PERL)' ENGDIRS='$(ENGDIRS)' \
|
||||
SDIRS='$(SDIRS)' LIBRPATH='$(INSTALLTOP)/$(LIBDIR)' \
|
||||
@@ -366,6 +368,7 @@ libcrypto.pc: Makefile
|
||||
echo 'exec_prefix=$${prefix}'; \
|
||||
echo 'libdir=$${exec_prefix}/$(LIBDIR)'; \
|
||||
echo 'includedir=$${prefix}/include'; \
|
||||
echo 'enginesdir=$${libdir}/engines'; \
|
||||
echo ''; \
|
||||
echo 'Name: OpenSSL-libcrypto'; \
|
||||
echo 'Description: OpenSSL cryptography library'; \
|
||||
|
||||
@@ -293,7 +293,7 @@ link_a.cygwin:
|
||||
fi; \
|
||||
dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
|
||||
$(PERL) util/mkrc.pl $$dll_name | \
|
||||
$(CROSS_COMPILE)windres -o rc.o; \
|
||||
$(RC) -o rc.o; \
|
||||
extras="$$extras rc.o"; \
|
||||
ALLSYMSFLAGS='-Wl,--whole-archive'; \
|
||||
NOALLSYMSFLAGS='-Wl,--no-whole-archive'; \
|
||||
|
||||
@@ -5,6 +5,20 @@
|
||||
This file gives a brief overview of the major changes between each OpenSSL
|
||||
release. For more details please read the CHANGES file.
|
||||
|
||||
Major changes between OpenSSL 1.0.2h and OpenSSL 1.0.2i [22 Sep 2016]
|
||||
|
||||
o OCSP Status Request extension unbounded memory growth (CVE-2016-6304)
|
||||
o SWEET32 Mitigation (CVE-2016-2183)
|
||||
o OOB write in MDC2_Update() (CVE-2016-6303)
|
||||
o Malformed SHA512 ticket DoS (CVE-2016-6302)
|
||||
o OOB write in BN_bn2dec() (CVE-2016-2182)
|
||||
o OOB read in TS_OBJ_print_bio() (CVE-2016-2180)
|
||||
o Pointer arithmetic undefined behaviour (CVE-2016-2177)
|
||||
o Constant time flag not preserved in DSA signing (CVE-2016-2178)
|
||||
o DTLS buffered message DoS (CVE-2016-2179)
|
||||
o DTLS replay protection DoS (CVE-2016-2181)
|
||||
o Certificate message OOB reads (CVE-2016-6306)
|
||||
|
||||
Major changes between OpenSSL 1.0.2g and OpenSSL 1.0.2h [3 May 2016]
|
||||
|
||||
o Prevent padding oracle in AES-NI CBC MAC check (CVE-2016-2107)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
|
||||
OpenSSL 1.0.2h 3 May 2016
|
||||
OpenSSL 1.0.2i 22 Sep 2016
|
||||
|
||||
Copyright (c) 1998-2015 The OpenSSL Project
|
||||
Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson
|
||||
|
||||
@@ -64,7 +64,7 @@ $RET = 0;
|
||||
|
||||
foreach (@ARGV) {
|
||||
if ( /^(-\?|-h|-help)$/ ) {
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-signcert|-verify\n";
|
||||
exit 0;
|
||||
} elsif (/^-newcert$/) {
|
||||
# create a certificate
|
||||
@@ -186,4 +186,3 @@ while (<IN>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ $RET = 0;
|
||||
|
||||
foreach (@ARGV) {
|
||||
if ( /^(-\?|-h|-help)$/ ) {
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-verify\n";
|
||||
print STDERR "usage: CA -newcert|-newreq|-newreq-nodes|-newca|-sign|-signcert|-verify\n";
|
||||
exit 0;
|
||||
} elsif (/^-newcert$/) {
|
||||
# create a certificate
|
||||
@@ -186,4 +186,3 @@ while (<IN>) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -215,7 +215,8 @@ int args_from_file(char *file, int *argc, char **argv[])
|
||||
if (arg != NULL)
|
||||
OPENSSL_free(arg);
|
||||
arg = (char **)OPENSSL_malloc(sizeof(char *) * (i * 2));
|
||||
|
||||
if (arg == NULL)
|
||||
return 0;
|
||||
*argv = arg;
|
||||
num = 0;
|
||||
p = buf;
|
||||
@@ -2374,6 +2375,8 @@ int args_verify(char ***pargs, int *pargc,
|
||||
flags |= X509_V_FLAG_PARTIAL_CHAIN;
|
||||
else if (!strcmp(arg, "-no_alt_chains"))
|
||||
flags |= X509_V_FLAG_NO_ALT_CHAINS;
|
||||
else if (!strcmp(arg, "-allow_proxy_certs"))
|
||||
flags |= X509_V_FLAG_ALLOW_PROXY_CERTS;
|
||||
else
|
||||
return 0;
|
||||
|
||||
@@ -3195,6 +3198,36 @@ int app_isdir(const char *name)
|
||||
#endif
|
||||
|
||||
/* raw_read|write section */
|
||||
#if defined(__VMS)
|
||||
# include "vms_term_sock.h"
|
||||
static int stdin_sock = -1;
|
||||
|
||||
static void close_stdin_sock(void)
|
||||
{
|
||||
TerminalSocket (TERM_SOCK_DELETE, &stdin_sock);
|
||||
}
|
||||
|
||||
int fileno_stdin(void)
|
||||
{
|
||||
if (stdin_sock == -1) {
|
||||
TerminalSocket(TERM_SOCK_CREATE, &stdin_sock);
|
||||
atexit(close_stdin_sock);
|
||||
}
|
||||
|
||||
return stdin_sock;
|
||||
}
|
||||
#else
|
||||
int fileno_stdin(void)
|
||||
{
|
||||
return fileno(stdin);
|
||||
}
|
||||
#endif
|
||||
|
||||
int fileno_stdout(void)
|
||||
{
|
||||
return fileno(stdout);
|
||||
}
|
||||
|
||||
#if defined(_WIN32) && defined(STD_INPUT_HANDLE)
|
||||
int raw_read_stdin(void *buf, int siz)
|
||||
{
|
||||
@@ -3204,10 +3237,17 @@ int raw_read_stdin(void *buf, int siz)
|
||||
else
|
||||
return (-1);
|
||||
}
|
||||
#elif defined(__VMS)
|
||||
#include <sys/socket.h>
|
||||
|
||||
int raw_read_stdin(void *buf, int siz)
|
||||
{
|
||||
return recv(fileno_stdin(), buf, siz, 0);
|
||||
}
|
||||
#else
|
||||
int raw_read_stdin(void *buf, int siz)
|
||||
{
|
||||
return read(fileno(stdin), buf, siz);
|
||||
return read(fileno_stdin(), buf, siz);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -3223,6 +3263,6 @@ int raw_write_stdout(const void *buf, int siz)
|
||||
#else
|
||||
int raw_write_stdout(const void *buf, int siz)
|
||||
{
|
||||
return write(fileno(stdout), buf, siz);
|
||||
return write(fileno_stdout(), buf, siz);
|
||||
}
|
||||
#endif
|
||||
@@ -375,6 +375,8 @@ void store_setup_crl_download(X509_STORE *st);
|
||||
# define SERIAL_RAND_BITS 64
|
||||
|
||||
int app_isdir(const char *);
|
||||
int fileno_stdin(void);
|
||||
int fileno_stdout(void);
|
||||
int raw_read_stdin(void *, int);
|
||||
int raw_write_stdout(const void *, int);
|
||||
|
||||
|
||||
+11
-12
@@ -2103,25 +2103,23 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509,
|
||||
goto err;
|
||||
|
||||
/* We now just add it to the database */
|
||||
row[DB_type] = (char *)OPENSSL_malloc(2);
|
||||
|
||||
tm = X509_get_notAfter(ret);
|
||||
row[DB_exp_date] = (char *)OPENSSL_malloc(tm->length + 1);
|
||||
memcpy(row[DB_exp_date], tm->data, tm->length);
|
||||
row[DB_exp_date][tm->length] = '\0';
|
||||
|
||||
row[DB_rev_date] = NULL;
|
||||
|
||||
/* row[DB_serial] done already */
|
||||
row[DB_file] = (char *)OPENSSL_malloc(8);
|
||||
row[DB_type] = OPENSSL_malloc(2);
|
||||
row[DB_exp_date] = OPENSSL_malloc(tm->length + 1);
|
||||
row[DB_rev_date] = OPENSSL_malloc(1);
|
||||
row[DB_file] = OPENSSL_malloc(8);
|
||||
row[DB_name] = X509_NAME_oneline(X509_get_subject_name(ret), NULL, 0);
|
||||
|
||||
if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
|
||||
(row[DB_rev_date] == NULL) ||
|
||||
(row[DB_file] == NULL) || (row[DB_name] == NULL)) {
|
||||
BIO_printf(bio_err, "Memory allocation failure\n");
|
||||
goto err;
|
||||
}
|
||||
BUF_strlcpy(row[DB_file], "unknown", 8);
|
||||
|
||||
memcpy(row[DB_exp_date], tm->data, tm->length);
|
||||
row[DB_exp_date][tm->length] = '\0';
|
||||
row[DB_rev_date][0] = '\0';
|
||||
strcpy(row[DB_file], "unknown");
|
||||
row[DB_type][0] = 'V';
|
||||
row[DB_type][1] = '\0';
|
||||
|
||||
@@ -2307,6 +2305,7 @@ static int certify_spkac(X509 **xret, char *infile, EVP_PKEY *pkey,
|
||||
|
||||
j = NETSCAPE_SPKI_verify(spki, pktmp);
|
||||
if (j <= 0) {
|
||||
EVP_PKEY_free(pktmp);
|
||||
BIO_printf(bio_err,
|
||||
"signature verification failed on SPKAC public key\n");
|
||||
goto err;
|
||||
|
||||
@@ -243,6 +243,11 @@ int MAIN(int argc, char **argv)
|
||||
argv++;
|
||||
}
|
||||
|
||||
if (keyfile != NULL && argc > 1) {
|
||||
BIO_printf(bio_err, "Can only sign or verify one file\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (do_verify && !sigfile) {
|
||||
BIO_printf(bio_err,
|
||||
"No signature to verify: use the -signature option\n");
|
||||
|
||||
@@ -509,7 +509,7 @@ int MAIN(int argc, char **argv)
|
||||
BIO_printf(bio_err, "invalid hex salt value\n");
|
||||
goto end;
|
||||
}
|
||||
} else if (RAND_pseudo_bytes(salt, sizeof salt) < 0)
|
||||
} else if (RAND_bytes(salt, sizeof salt) <= 0)
|
||||
goto end;
|
||||
/*
|
||||
* If -P option then don't bother writing
|
||||
|
||||
@@ -416,7 +416,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
|
||||
if (*salt_malloc_p == NULL)
|
||||
goto err;
|
||||
}
|
||||
if (RAND_pseudo_bytes((unsigned char *)*salt_p, 2) < 0)
|
||||
if (RAND_bytes((unsigned char *)*salt_p, 2) <= 0)
|
||||
goto err;
|
||||
(*salt_p)[0] = cov_2char[(*salt_p)[0] & 0x3f]; /* 6 bits */
|
||||
(*salt_p)[1] = cov_2char[(*salt_p)[1] & 0x3f]; /* 6 bits */
|
||||
@@ -437,7 +437,7 @@ static int do_passwd(int passed_salt, char **salt_p, char **salt_malloc_p,
|
||||
if (*salt_malloc_p == NULL)
|
||||
goto err;
|
||||
}
|
||||
if (RAND_pseudo_bytes((unsigned char *)*salt_p, 8) < 0)
|
||||
if (RAND_bytes((unsigned char *)*salt_p, 8) <= 0)
|
||||
goto err;
|
||||
|
||||
for (i = 0; i < 8; i++)
|
||||
|
||||
@@ -832,6 +832,7 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
|
||||
EVP_PKEY *pkey;
|
||||
PKCS8_PRIV_KEY_INFO *p8;
|
||||
X509 *x509;
|
||||
int ret = 0;
|
||||
|
||||
switch (M_PKCS12_bag_type(bag)) {
|
||||
case NID_keyBag:
|
||||
@@ -844,7 +845,7 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
|
||||
if (!(pkey = EVP_PKCS82PKEY(p8)))
|
||||
return 0;
|
||||
print_attribs(out, p8->attributes, "Key Attributes");
|
||||
PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
|
||||
ret = PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
|
||||
EVP_PKEY_free(pkey);
|
||||
break;
|
||||
|
||||
@@ -864,7 +865,7 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
|
||||
}
|
||||
print_attribs(out, p8->attributes, "Key Attributes");
|
||||
PKCS8_PRIV_KEY_INFO_free(p8);
|
||||
PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
|
||||
ret = PEM_write_bio_PrivateKey(out, pkey, enc, NULL, 0, NULL, pempass);
|
||||
EVP_PKEY_free(pkey);
|
||||
break;
|
||||
|
||||
@@ -884,7 +885,7 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
|
||||
if (!(x509 = PKCS12_certbag2x509(bag)))
|
||||
return 0;
|
||||
dump_cert_text(out, x509);
|
||||
PEM_write_bio_X509(out, x509);
|
||||
ret = PEM_write_bio_X509(out, x509);
|
||||
X509_free(x509);
|
||||
break;
|
||||
|
||||
@@ -902,7 +903,7 @@ int dump_certs_pkeys_bag(BIO *out, PKCS12_SAFEBAG *bag, char *pass,
|
||||
return 1;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* Given a single certificate return a verified chain or NULL if error */
|
||||
@@ -931,16 +932,70 @@ static int get_cert_chain(X509 *cert, X509_STORE *store,
|
||||
|
||||
int alg_print(BIO *x, X509_ALGOR *alg)
|
||||
{
|
||||
PBEPARAM *pbe;
|
||||
const unsigned char *p;
|
||||
p = alg->parameter->value.sequence->data;
|
||||
pbe = d2i_PBEPARAM(NULL, &p, alg->parameter->value.sequence->length);
|
||||
if (!pbe)
|
||||
return 1;
|
||||
BIO_printf(bio_err, "%s, Iteration %ld\n",
|
||||
OBJ_nid2ln(OBJ_obj2nid(alg->algorithm)),
|
||||
ASN1_INTEGER_get(pbe->iter));
|
||||
PBEPARAM_free(pbe);
|
||||
int pbenid, aparamtype;
|
||||
ASN1_OBJECT *aoid;
|
||||
void *aparam;
|
||||
PBEPARAM *pbe = NULL;
|
||||
|
||||
X509_ALGOR_get0(&aoid, &aparamtype, &aparam, alg);
|
||||
|
||||
pbenid = OBJ_obj2nid(aoid);
|
||||
|
||||
BIO_printf(x, "%s", OBJ_nid2ln(pbenid));
|
||||
|
||||
/*
|
||||
* If PBE algorithm is PBES2 decode algorithm parameters
|
||||
* for additional details.
|
||||
*/
|
||||
if (pbenid == NID_pbes2) {
|
||||
PBE2PARAM *pbe2 = NULL;
|
||||
int encnid;
|
||||
if (aparamtype == V_ASN1_SEQUENCE)
|
||||
pbe2 = ASN1_item_unpack(aparam, ASN1_ITEM_rptr(PBE2PARAM));
|
||||
if (pbe2 == NULL) {
|
||||
BIO_puts(x, "<unsupported parameters>");
|
||||
goto done;
|
||||
}
|
||||
X509_ALGOR_get0(&aoid, &aparamtype, &aparam, pbe2->keyfunc);
|
||||
pbenid = OBJ_obj2nid(aoid);
|
||||
X509_ALGOR_get0(&aoid, NULL, NULL, pbe2->encryption);
|
||||
encnid = OBJ_obj2nid(aoid);
|
||||
BIO_printf(x, ", %s, %s", OBJ_nid2ln(pbenid),
|
||||
OBJ_nid2sn(encnid));
|
||||
/* If KDF is PBKDF2 decode parameters */
|
||||
if (pbenid == NID_id_pbkdf2) {
|
||||
PBKDF2PARAM *kdf = NULL;
|
||||
int prfnid;
|
||||
if (aparamtype == V_ASN1_SEQUENCE)
|
||||
kdf = ASN1_item_unpack(aparam, ASN1_ITEM_rptr(PBKDF2PARAM));
|
||||
if (kdf == NULL) {
|
||||
BIO_puts(x, "<unsupported parameters>");
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (kdf->prf == NULL) {
|
||||
prfnid = NID_hmacWithSHA1;
|
||||
} else {
|
||||
X509_ALGOR_get0(&aoid, NULL, NULL, kdf->prf);
|
||||
prfnid = OBJ_obj2nid(aoid);
|
||||
}
|
||||
BIO_printf(x, ", Iteration %ld, PRF %s",
|
||||
ASN1_INTEGER_get(kdf->iter), OBJ_nid2sn(prfnid));
|
||||
PBKDF2PARAM_free(kdf);
|
||||
}
|
||||
PBE2PARAM_free(pbe2);
|
||||
} else {
|
||||
if (aparamtype == V_ASN1_SEQUENCE)
|
||||
pbe = ASN1_item_unpack(aparam, ASN1_ITEM_rptr(PBEPARAM));
|
||||
if (pbe == NULL) {
|
||||
BIO_puts(x, "<unsupported parameters>");
|
||||
goto done;
|
||||
}
|
||||
BIO_printf(x, ", Iteration %ld", ASN1_INTEGER_get(pbe->iter));
|
||||
PBEPARAM_free(pbe);
|
||||
}
|
||||
done:
|
||||
BIO_puts(x, "\n");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -332,9 +332,10 @@ int MAIN(int argc, char **argv)
|
||||
subject = 1;
|
||||
else if (strcmp(*argv, "-text") == 0)
|
||||
text = 1;
|
||||
else if (strcmp(*argv, "-x509") == 0)
|
||||
else if (strcmp(*argv, "-x509") == 0) {
|
||||
newreq = 1;
|
||||
x509 = 1;
|
||||
else if (strcmp(*argv, "-asn1-kludge") == 0)
|
||||
} else if (strcmp(*argv, "-asn1-kludge") == 0)
|
||||
kludge = 1;
|
||||
else if (strcmp(*argv, "-no-asn1-kludge") == 0)
|
||||
kludge = 0;
|
||||
@@ -756,7 +757,7 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (newreq || x509) {
|
||||
if (newreq) {
|
||||
if (pkey == NULL) {
|
||||
BIO_printf(bio_err, "you need to specify a private key\n");
|
||||
goto end;
|
||||
@@ -1331,12 +1332,11 @@ static int auto_info(X509_REQ *req, STACK_OF(CONF_VALUE) *dn_sk,
|
||||
break;
|
||||
}
|
||||
#ifndef CHARSET_EBCDIC
|
||||
if (*p == '+')
|
||||
if (*type == '+') {
|
||||
#else
|
||||
if (*p == os_toascii['+'])
|
||||
if (*type == os_toascii['+']) {
|
||||
#endif
|
||||
{
|
||||
p++;
|
||||
type++;
|
||||
mval = -1;
|
||||
} else
|
||||
mval = 0;
|
||||
|
||||
@@ -199,7 +199,8 @@ int load_excert(SSL_EXCERT **pexc, BIO *err);
|
||||
void print_ssl_summary(BIO *bio, SSL *s);
|
||||
#ifdef HEADER_SSL_H
|
||||
int args_ssl(char ***pargs, int *pargc, SSL_CONF_CTX *cctx,
|
||||
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr);
|
||||
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr,
|
||||
int *no_prot_opt);
|
||||
int args_ssl_call(SSL_CTX *ctx, BIO *err, SSL_CONF_CTX *cctx,
|
||||
STACK_OF(OPENSSL_STRING) *str, int no_ecdhe, int no_jpake);
|
||||
int ssl_ctx_add_crls(SSL_CTX *ctx, STACK_OF(X509_CRL) *crls,
|
||||
|
||||
@@ -1507,11 +1507,18 @@ void print_ssl_summary(BIO *bio, SSL *s)
|
||||
}
|
||||
|
||||
int args_ssl(char ***pargs, int *pargc, SSL_CONF_CTX *cctx,
|
||||
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr)
|
||||
int *badarg, BIO *err, STACK_OF(OPENSSL_STRING) **pstr,
|
||||
int *no_prot_opt)
|
||||
{
|
||||
char *arg = **pargs, *argn = (*pargs)[1];
|
||||
int rv;
|
||||
|
||||
if (strcmp(arg, "-no_ssl2") == 0 || strcmp(arg, "-no_ssl3") == 0
|
||||
|| strcmp(arg, "-no_tls1") == 0 || strcmp(arg, "-no_tls1_1") == 0
|
||||
|| strcmp(arg, "-no_tls1_2") == 0) {
|
||||
*no_prot_opt = 1;
|
||||
}
|
||||
|
||||
/* Attempt to run SSL configuration command */
|
||||
rv = SSL_CONF_cmd_argv(cctx, pargc, pargs);
|
||||
/* If parameter not recognised just return */
|
||||
|
||||
@@ -242,9 +242,9 @@ static unsigned int psk_client_cb(SSL *ssl, const char *hint, char *identity,
|
||||
unsigned char *psk,
|
||||
unsigned int max_psk_len)
|
||||
{
|
||||
unsigned int psk_len = 0;
|
||||
int ret;
|
||||
BIGNUM *bn = NULL;
|
||||
long key_len;
|
||||
unsigned char *key;
|
||||
|
||||
if (c_debug)
|
||||
BIO_printf(bio_c_out, "psk_client_cb\n");
|
||||
@@ -265,32 +265,29 @@ static unsigned int psk_client_cb(SSL *ssl, const char *hint, char *identity,
|
||||
if (c_debug)
|
||||
BIO_printf(bio_c_out, "created identity '%s' len=%d\n", identity,
|
||||
ret);
|
||||
ret = BN_hex2bn(&bn, psk_key);
|
||||
if (!ret) {
|
||||
BIO_printf(bio_err, "Could not convert PSK key '%s' to BIGNUM\n",
|
||||
|
||||
/* convert the PSK key to binary */
|
||||
key = string_to_hex(psk_key, &key_len);
|
||||
if (key == NULL) {
|
||||
BIO_printf(bio_err, "Could not convert PSK key '%s' to buffer\n",
|
||||
psk_key);
|
||||
if (bn)
|
||||
BN_free(bn);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((unsigned int)BN_num_bytes(bn) > max_psk_len) {
|
||||
if ((unsigned long)key_len > (unsigned long)max_psk_len) {
|
||||
BIO_printf(bio_err,
|
||||
"psk buffer of callback is too small (%d) for key (%d)\n",
|
||||
max_psk_len, BN_num_bytes(bn));
|
||||
BN_free(bn);
|
||||
"psk buffer of callback is too small (%d) for key (%ld)\n",
|
||||
max_psk_len, key_len);
|
||||
OPENSSL_free(key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
psk_len = BN_bn2bin(bn, psk);
|
||||
BN_free(bn);
|
||||
if (psk_len == 0)
|
||||
goto out_err;
|
||||
memcpy(psk, key, key_len);
|
||||
OPENSSL_free(key);
|
||||
|
||||
if (c_debug)
|
||||
BIO_printf(bio_c_out, "created PSK len=%d\n", psk_len);
|
||||
BIO_printf(bio_c_out, "created PSK len=%ld\n", key_len);
|
||||
|
||||
return psk_len;
|
||||
return key_len;
|
||||
out_err:
|
||||
if (c_debug)
|
||||
BIO_printf(bio_err, "Error in PSK client callback\n");
|
||||
@@ -747,6 +744,7 @@ int MAIN(int argc, char **argv)
|
||||
int crl_format = FORMAT_PEM;
|
||||
int crl_download = 0;
|
||||
STACK_OF(X509_CRL) *crls = NULL;
|
||||
int prot_opt = 0, no_prot_opt = 0;
|
||||
|
||||
meth = SSLv23_client_method();
|
||||
|
||||
@@ -850,7 +848,8 @@ int MAIN(int argc, char **argv)
|
||||
if (badarg)
|
||||
goto bad;
|
||||
continue;
|
||||
} else if (args_ssl(&argv, &argc, cctx, &badarg, bio_err, &ssl_args)) {
|
||||
} else if (args_ssl(&argv, &argc, cctx, &badarg, bio_err, &ssl_args,
|
||||
&no_prot_opt)) {
|
||||
if (badarg)
|
||||
goto bad;
|
||||
continue;
|
||||
@@ -942,31 +941,42 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL2
|
||||
else if (strcmp(*argv, "-ssl2") == 0)
|
||||
else if (strcmp(*argv, "-ssl2") == 0) {
|
||||
meth = SSLv2_client_method();
|
||||
prot_opt++;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
else if (strcmp(*argv, "-ssl3") == 0)
|
||||
else if (strcmp(*argv, "-ssl3") == 0) {
|
||||
meth = SSLv3_client_method();
|
||||
prot_opt++;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1
|
||||
else if (strcmp(*argv, "-tls1_2") == 0)
|
||||
else if (strcmp(*argv, "-tls1_2") == 0) {
|
||||
meth = TLSv1_2_client_method();
|
||||
else if (strcmp(*argv, "-tls1_1") == 0)
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-tls1_1") == 0) {
|
||||
meth = TLSv1_1_client_method();
|
||||
else if (strcmp(*argv, "-tls1") == 0)
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-tls1") == 0) {
|
||||
meth = TLSv1_client_method();
|
||||
prot_opt++;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DTLS1
|
||||
else if (strcmp(*argv, "-dtls") == 0) {
|
||||
meth = DTLS_client_method();
|
||||
socket_type = SOCK_DGRAM;
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-dtls1") == 0) {
|
||||
meth = DTLSv1_client_method();
|
||||
socket_type = SOCK_DGRAM;
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-dtls1_2") == 0) {
|
||||
meth = DTLSv1_2_client_method();
|
||||
socket_type = SOCK_DGRAM;
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-timeout") == 0)
|
||||
enable_timeouts = 1;
|
||||
else if (strcmp(*argv, "-mtu") == 0) {
|
||||
@@ -1149,6 +1159,17 @@ int MAIN(int argc, char **argv)
|
||||
}
|
||||
#endif
|
||||
|
||||
if (prot_opt > 1) {
|
||||
BIO_printf(bio_err, "Cannot supply multiple protocol flags\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (prot_opt == 1 && no_prot_opt) {
|
||||
BIO_printf(bio_err, "Cannot supply both a protocol flag and "
|
||||
"\"-no_<prot>\"\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
SSL_load_error_strings();
|
||||
|
||||
@@ -1540,7 +1561,10 @@ int MAIN(int argc, char **argv)
|
||||
SSL_set_connect_state(con);
|
||||
|
||||
/* ok, lets connect */
|
||||
width = SSL_get_fd(con) + 1;
|
||||
if (fileno_stdin() > SSL_get_fd(con))
|
||||
width = fileno_stdin() + 1;
|
||||
else
|
||||
width = SSL_get_fd(con) + 1;
|
||||
|
||||
read_tty = 1;
|
||||
write_tty = 0;
|
||||
@@ -1723,9 +1747,11 @@ int MAIN(int argc, char **argv)
|
||||
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE) && !defined (OPENSSL_SYS_BEOS_R5)
|
||||
if (tty_on) {
|
||||
if (read_tty)
|
||||
openssl_fdset(fileno(stdin), &readfds);
|
||||
openssl_fdset(fileno_stdin(), &readfds);
|
||||
#if !defined(OPENSSL_SYS_VMS)
|
||||
if (write_tty)
|
||||
openssl_fdset(fileno(stdout), &writefds);
|
||||
openssl_fdset(fileno_stdout(), &writefds);
|
||||
#endif
|
||||
}
|
||||
if (read_ssl)
|
||||
openssl_fdset(SSL_get_fd(con), &readfds);
|
||||
@@ -1795,14 +1821,14 @@ int MAIN(int argc, char **argv)
|
||||
/* Under BeOS-R5 the situation is similar to DOS */
|
||||
i = 0;
|
||||
stdin_set = 0;
|
||||
(void)fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
|
||||
(void)fcntl(fileno_stdin(), F_SETFL, O_NONBLOCK);
|
||||
if (!write_tty) {
|
||||
if (read_tty) {
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 0;
|
||||
i = select(width, (void *)&readfds, (void *)&writefds,
|
||||
NULL, &tv);
|
||||
if (read(fileno(stdin), sbuf, 0) >= 0)
|
||||
if (read(fileno_stdin(), sbuf, 0) >= 0)
|
||||
stdin_set = 1;
|
||||
if (!i && (stdin_set != 1 || !read_tty))
|
||||
continue;
|
||||
@@ -1810,7 +1836,7 @@ int MAIN(int argc, char **argv)
|
||||
i = select(width, (void *)&readfds, (void *)&writefds,
|
||||
NULL, timeoutp);
|
||||
}
|
||||
(void)fcntl(fileno(stdin), F_SETFL, 0);
|
||||
(void)fcntl(fileno_stdin(), F_SETFL, 0);
|
||||
#else
|
||||
i = select(width, (void *)&readfds, (void *)&writefds,
|
||||
NULL, timeoutp);
|
||||
@@ -1886,11 +1912,11 @@ int MAIN(int argc, char **argv)
|
||||
goto shut;
|
||||
}
|
||||
}
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS_R5)
|
||||
#if defined(OPENSSL_SYS_WINDOWS) || defined(OPENSSL_SYS_MSDOS) || defined(OPENSSL_SYS_NETWARE) || defined(OPENSSL_SYS_BEOS_R5) || defined(OPENSSL_SYS_VMS)
|
||||
/* Assume Windows/DOS/BeOS can always write */
|
||||
else if (!ssl_pending && write_tty)
|
||||
#else
|
||||
else if (!ssl_pending && FD_ISSET(fileno(stdout), &writefds))
|
||||
else if (!ssl_pending && FD_ISSET(fileno_stdout(), &writefds))
|
||||
#endif
|
||||
{
|
||||
#ifdef CHARSET_EBCDIC
|
||||
@@ -1988,7 +2014,7 @@ int MAIN(int argc, char **argv)
|
||||
#elif defined(OPENSSL_SYS_BEOS_R5)
|
||||
else if (stdin_set)
|
||||
#else
|
||||
else if (FD_ISSET(fileno(stdin), &readfds))
|
||||
else if (FD_ISSET(fileno_stdin(), &readfds))
|
||||
#endif
|
||||
{
|
||||
if (crlf) {
|
||||
|
||||
@@ -353,9 +353,8 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity,
|
||||
unsigned char *psk,
|
||||
unsigned int max_psk_len)
|
||||
{
|
||||
unsigned int psk_len = 0;
|
||||
int ret;
|
||||
BIGNUM *bn = NULL;
|
||||
long key_len = 0;
|
||||
unsigned char *key;
|
||||
|
||||
if (s_debug)
|
||||
BIO_printf(bio_s_out, "psk_server_cb\n");
|
||||
@@ -377,32 +376,26 @@ static unsigned int psk_server_cb(SSL *ssl, const char *identity,
|
||||
BIO_printf(bio_s_out, "PSK client identity found\n");
|
||||
|
||||
/* convert the PSK key to binary */
|
||||
ret = BN_hex2bn(&bn, psk_key);
|
||||
if (!ret) {
|
||||
BIO_printf(bio_err, "Could not convert PSK key '%s' to BIGNUM\n",
|
||||
key = string_to_hex(psk_key, &key_len);
|
||||
if (key == NULL) {
|
||||
BIO_printf(bio_err, "Could not convert PSK key '%s' to buffer\n",
|
||||
psk_key);
|
||||
if (bn)
|
||||
BN_free(bn);
|
||||
return 0;
|
||||
}
|
||||
if (BN_num_bytes(bn) > (int)max_psk_len) {
|
||||
if (key_len > (int)max_psk_len) {
|
||||
BIO_printf(bio_err,
|
||||
"psk buffer of callback is too small (%d) for key (%d)\n",
|
||||
max_psk_len, BN_num_bytes(bn));
|
||||
BN_free(bn);
|
||||
"psk buffer of callback is too small (%d) for key (%ld)\n",
|
||||
max_psk_len, key_len);
|
||||
OPENSSL_free(key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
ret = BN_bn2bin(bn, psk);
|
||||
BN_free(bn);
|
||||
|
||||
if (ret < 0)
|
||||
goto out_err;
|
||||
psk_len = (unsigned int)ret;
|
||||
memcpy(psk, key, key_len);
|
||||
OPENSSL_free(key);
|
||||
|
||||
if (s_debug)
|
||||
BIO_printf(bio_s_out, "fetched PSK len=%d\n", psk_len);
|
||||
return psk_len;
|
||||
BIO_printf(bio_s_out, "fetched PSK len=%ld\n", key_len);
|
||||
return key_len;
|
||||
out_err:
|
||||
if (s_debug)
|
||||
BIO_printf(bio_err, "Error in PSK server callback\n");
|
||||
@@ -1144,6 +1137,7 @@ int MAIN(int argc, char *argv[])
|
||||
int crl_format = FORMAT_PEM;
|
||||
int crl_download = 0;
|
||||
STACK_OF(X509_CRL) *crls = NULL;
|
||||
int prot_opt = 0, no_prot_opt = 0;
|
||||
|
||||
meth = SSLv23_server_method();
|
||||
|
||||
@@ -1307,7 +1301,8 @@ int MAIN(int argc, char *argv[])
|
||||
if (badarg)
|
||||
goto bad;
|
||||
continue;
|
||||
} else if (args_ssl(&argv, &argc, cctx, &badarg, bio_err, &ssl_args)) {
|
||||
} else if (args_ssl(&argv, &argc, cctx, &badarg, bio_err, &ssl_args,
|
||||
&no_prot_opt)) {
|
||||
if (badarg)
|
||||
goto bad;
|
||||
continue;
|
||||
@@ -1451,32 +1446,40 @@ int MAIN(int argc, char *argv[])
|
||||
else if (strcmp(*argv, "-ssl2") == 0) {
|
||||
no_ecdhe = 1;
|
||||
meth = SSLv2_server_method();
|
||||
prot_opt++;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_SSL3_METHOD
|
||||
else if (strcmp(*argv, "-ssl3") == 0) {
|
||||
meth = SSLv3_server_method();
|
||||
prot_opt++;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_TLS1
|
||||
else if (strcmp(*argv, "-tls1") == 0) {
|
||||
meth = TLSv1_server_method();
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-tls1_1") == 0) {
|
||||
meth = TLSv1_1_server_method();
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-tls1_2") == 0) {
|
||||
meth = TLSv1_2_server_method();
|
||||
prot_opt++;
|
||||
}
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DTLS1
|
||||
else if (strcmp(*argv, "-dtls") == 0) {
|
||||
meth = DTLS_server_method();
|
||||
socket_type = SOCK_DGRAM;
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-dtls1") == 0) {
|
||||
meth = DTLSv1_server_method();
|
||||
socket_type = SOCK_DGRAM;
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-dtls1_2") == 0) {
|
||||
meth = DTLSv1_2_server_method();
|
||||
socket_type = SOCK_DGRAM;
|
||||
prot_opt++;
|
||||
} else if (strcmp(*argv, "-timeout") == 0)
|
||||
enable_timeouts = 1;
|
||||
else if (strcmp(*argv, "-mtu") == 0) {
|
||||
@@ -1586,6 +1589,17 @@ int MAIN(int argc, char *argv[])
|
||||
}
|
||||
#endif
|
||||
|
||||
if (prot_opt > 1) {
|
||||
BIO_printf(bio_err, "Cannot supply multiple protocol flags\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (prot_opt == 1 && no_prot_opt) {
|
||||
BIO_printf(bio_err, "Cannot supply both a protocol flag and "
|
||||
"\"-no_<prot>\"\n");
|
||||
goto end;
|
||||
}
|
||||
|
||||
SSL_load_error_strings();
|
||||
OpenSSL_add_ssl_algorithms();
|
||||
|
||||
@@ -2293,7 +2307,10 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
}
|
||||
#endif
|
||||
|
||||
width = s + 1;
|
||||
if (fileno_stdin() > s)
|
||||
width = fileno_stdin() + 1;
|
||||
else
|
||||
width = s + 1;
|
||||
for (;;) {
|
||||
int read_from_terminal;
|
||||
int read_from_sslcon;
|
||||
@@ -2304,7 +2321,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
if (!read_from_sslcon) {
|
||||
FD_ZERO(&readfds);
|
||||
#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MSDOS) && !defined(OPENSSL_SYS_NETWARE) && !defined(OPENSSL_SYS_BEOS_R5)
|
||||
openssl_fdset(fileno(stdin), &readfds);
|
||||
openssl_fdset(fileno_stdin(), &readfds);
|
||||
#endif
|
||||
openssl_fdset(s, &readfds);
|
||||
/*
|
||||
@@ -2332,13 +2349,13 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
/* Under BeOS-R5 the situation is similar to DOS */
|
||||
tv.tv_sec = 1;
|
||||
tv.tv_usec = 0;
|
||||
(void)fcntl(fileno(stdin), F_SETFL, O_NONBLOCK);
|
||||
(void)fcntl(fileno_stdin(), F_SETFL, O_NONBLOCK);
|
||||
i = select(width, (void *)&readfds, NULL, NULL, &tv);
|
||||
if ((i < 0) || (!i && read(fileno(stdin), buf, 0) < 0))
|
||||
if ((i < 0) || (!i && read(fileno_stdin(), buf, 0) < 0))
|
||||
continue;
|
||||
if (read(fileno(stdin), buf, 0) >= 0)
|
||||
if (read(fileno_stdin(), buf, 0) >= 0)
|
||||
read_from_terminal = 1;
|
||||
(void)fcntl(fileno(stdin), F_SETFL, 0);
|
||||
(void)fcntl(fileno_stdin(), F_SETFL, 0);
|
||||
#else
|
||||
if ((SSL_version(con) == DTLS1_VERSION) &&
|
||||
DTLSv1_get_timeout(con, &timeout))
|
||||
@@ -2355,7 +2372,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
|
||||
if (i <= 0)
|
||||
continue;
|
||||
if (FD_ISSET(fileno(stdin), &readfds))
|
||||
if (FD_ISSET(fileno_stdin(), &readfds))
|
||||
read_from_terminal = 1;
|
||||
#endif
|
||||
if (FD_ISSET(s, &readfds))
|
||||
@@ -2382,6 +2399,7 @@ static int sv_body(char *hostname, int s, int stype, unsigned char *context)
|
||||
assert(lf_num == 0);
|
||||
} else
|
||||
i = raw_read_stdin(buf, bufsize);
|
||||
|
||||
if (!s_quiet && !s_brief) {
|
||||
if ((i <= 0) || (buf[0] == 'Q')) {
|
||||
BIO_printf(bio_s_out, "DONE\n");
|
||||
@@ -3371,7 +3389,7 @@ static int generate_session_id(const SSL *ssl, unsigned char *id,
|
||||
{
|
||||
unsigned int count = 0;
|
||||
do {
|
||||
if (RAND_pseudo_bytes(id, *id_len) < 0)
|
||||
if (RAND_bytes(id, *id_len) <= 0)
|
||||
return 0;
|
||||
/*
|
||||
* Prefix the session_id with the required prefix. NB: If our prefix
|
||||
|
||||
@@ -2614,6 +2614,10 @@ static int do_multi(int multi)
|
||||
static char sep[] = ":";
|
||||
|
||||
fds = malloc(multi * sizeof *fds);
|
||||
if (fds == NULL) {
|
||||
fprintf(stderr, "Out of memory in speed (do_multi)\n");
|
||||
exit(1);
|
||||
}
|
||||
for (n = 0; n < multi; ++n) {
|
||||
if (pipe(fd) == -1) {
|
||||
fprintf(stderr, "pipe failure\n");
|
||||
|
||||
@@ -765,4 +765,6 @@ int MAIN(int argc, char **argv)
|
||||
OPENSSL_EXIT(ret);
|
||||
}
|
||||
|
||||
#else
|
||||
static void *dummy = &dummy;
|
||||
#endif
|
||||
@@ -115,43 +115,43 @@ int MAIN(int argc, char **argv)
|
||||
if (argc >= 1) {
|
||||
if (strcmp(*argv, "-CApath") == 0) {
|
||||
if (argc-- < 1)
|
||||
goto end;
|
||||
goto usage;
|
||||
CApath = *(++argv);
|
||||
} else if (strcmp(*argv, "-CAfile") == 0) {
|
||||
if (argc-- < 1)
|
||||
goto end;
|
||||
goto usage;
|
||||
CAfile = *(++argv);
|
||||
} else if (args_verify(&argv, &argc, &badarg, bio_err, &vpm)) {
|
||||
if (badarg)
|
||||
goto end;
|
||||
goto usage;
|
||||
continue;
|
||||
} else if (strcmp(*argv, "-untrusted") == 0) {
|
||||
if (argc-- < 1)
|
||||
goto end;
|
||||
goto usage;
|
||||
untfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-trusted") == 0) {
|
||||
if (argc-- < 1)
|
||||
goto end;
|
||||
goto usage;
|
||||
trustfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-CRLfile") == 0) {
|
||||
if (argc-- < 1)
|
||||
goto end;
|
||||
goto usage;
|
||||
crlfile = *(++argv);
|
||||
} else if (strcmp(*argv, "-crl_download") == 0)
|
||||
crl_download = 1;
|
||||
#ifndef OPENSSL_NO_ENGINE
|
||||
else if (strcmp(*argv, "-engine") == 0) {
|
||||
if (--argc < 1)
|
||||
goto end;
|
||||
goto usage;
|
||||
engine = *(++argv);
|
||||
}
|
||||
#endif
|
||||
else if (strcmp(*argv, "-help") == 0)
|
||||
goto end;
|
||||
goto usage;
|
||||
else if (strcmp(*argv, "-verbose") == 0)
|
||||
v_verbose = 1;
|
||||
else if (argv[0][0] == '-')
|
||||
goto end;
|
||||
goto usage;
|
||||
else
|
||||
break;
|
||||
argc--;
|
||||
@@ -228,7 +228,7 @@ int MAIN(int argc, char **argv)
|
||||
ret = -1;
|
||||
}
|
||||
|
||||
end:
|
||||
usage:
|
||||
if (ret == 1) {
|
||||
BIO_printf(bio_err,
|
||||
"usage: verify [-verbose] [-CApath path] [-CAfile file] [-purpose purpose] [-crl_check]");
|
||||
@@ -247,6 +247,7 @@ int MAIN(int argc, char **argv)
|
||||
X509_PURPOSE_get0_name(ptmp));
|
||||
}
|
||||
}
|
||||
end:
|
||||
if (vpm)
|
||||
X509_VERIFY_PARAM_free(vpm);
|
||||
if (cert_ctx != NULL)
|
||||
|
||||
@@ -1105,6 +1105,10 @@ static int x509_certify(X509_STORE *ctx, char *CAfile, const EVP_MD *digest,
|
||||
EVP_PKEY *upkey;
|
||||
|
||||
upkey = X509_get_pubkey(xca);
|
||||
if (upkey == NULL) {
|
||||
BIO_printf(bio_err, "Error obtaining CA X509 public key\n");
|
||||
goto end;
|
||||
}
|
||||
EVP_PKEY_copy_parameters(upkey, pkey);
|
||||
EVP_PKEY_free(upkey);
|
||||
|
||||
@@ -1217,6 +1221,8 @@ static int sign(X509 *x, EVP_PKEY *pkey, int days, int clrext,
|
||||
EVP_PKEY *pktmp;
|
||||
|
||||
pktmp = X509_get_pubkey(x);
|
||||
if (pktmp == NULL)
|
||||
goto err;
|
||||
EVP_PKEY_copy_parameters(pktmp, pkey);
|
||||
EVP_PKEY_save_parameters(pktmp, 1);
|
||||
EVP_PKEY_free(pktmp);
|
||||
|
||||
@@ -1,7 +1,3 @@
|
||||
/*
|
||||
* $LP: LPlib/source/LPdir_unix.c,v 1.11 2004/09/23 22:07:22 _cvs_levitte Exp
|
||||
* $
|
||||
*/
|
||||
/*
|
||||
* Copyright (c) 2004, Richard Levitte <richard@levitte.org>
|
||||
* All rights reserved.
|
||||
|
||||
@@ -1797,8 +1797,6 @@ $code.=<<___;
|
||||
b .Lxts_enc_done
|
||||
.align 4
|
||||
.Lxts_enc_6:
|
||||
vst1.64 {@XMM[14]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[4], @XMM[4], @XMM[12]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -1834,8 +1832,6 @@ $code.=<<___;
|
||||
|
||||
.align 5
|
||||
.Lxts_enc_5:
|
||||
vst1.64 {@XMM[13]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[3], @XMM[3], @XMM[11]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -1864,8 +1860,6 @@ $code.=<<___;
|
||||
b .Lxts_enc_done
|
||||
.align 4
|
||||
.Lxts_enc_4:
|
||||
vst1.64 {@XMM[12]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[2], @XMM[2], @XMM[10]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -1891,8 +1885,6 @@ $code.=<<___;
|
||||
b .Lxts_enc_done
|
||||
.align 4
|
||||
.Lxts_enc_3:
|
||||
vst1.64 {@XMM[11]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[1], @XMM[1], @XMM[9]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -1917,8 +1909,6 @@ $code.=<<___;
|
||||
b .Lxts_enc_done
|
||||
.align 4
|
||||
.Lxts_enc_2:
|
||||
vst1.64 {@XMM[10]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[0], @XMM[0], @XMM[8]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -1941,7 +1931,7 @@ $code.=<<___;
|
||||
.align 4
|
||||
.Lxts_enc_1:
|
||||
mov r0, sp
|
||||
veor @XMM[0], @XMM[8]
|
||||
veor @XMM[0], @XMM[0], @XMM[8]
|
||||
mov r1, sp
|
||||
vst1.8 {@XMM[0]}, [sp,:128]
|
||||
mov r2, $key
|
||||
@@ -2251,8 +2241,6 @@ $code.=<<___;
|
||||
b .Lxts_dec_done
|
||||
.align 4
|
||||
.Lxts_dec_5:
|
||||
vst1.64 {@XMM[13]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[3], @XMM[3], @XMM[11]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -2281,8 +2269,6 @@ $code.=<<___;
|
||||
b .Lxts_dec_done
|
||||
.align 4
|
||||
.Lxts_dec_4:
|
||||
vst1.64 {@XMM[12]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[2], @XMM[2], @XMM[10]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -2308,8 +2294,6 @@ $code.=<<___;
|
||||
b .Lxts_dec_done
|
||||
.align 4
|
||||
.Lxts_dec_3:
|
||||
vst1.64 {@XMM[11]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[1], @XMM[1], @XMM[9]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -2334,8 +2318,6 @@ $code.=<<___;
|
||||
b .Lxts_dec_done
|
||||
.align 4
|
||||
.Lxts_dec_2:
|
||||
vst1.64 {@XMM[10]}, [r0,:128] @ next round tweak
|
||||
|
||||
veor @XMM[0], @XMM[0], @XMM[8]
|
||||
#ifndef BSAES_ASM_EXTENDED_KEY
|
||||
add r4, sp, #0x90 @ pass key schedule
|
||||
@@ -2358,12 +2340,12 @@ $code.=<<___;
|
||||
.align 4
|
||||
.Lxts_dec_1:
|
||||
mov r0, sp
|
||||
veor @XMM[0], @XMM[8]
|
||||
veor @XMM[0], @XMM[0], @XMM[8]
|
||||
mov r1, sp
|
||||
vst1.8 {@XMM[0]}, [sp,:128]
|
||||
mov r5, $magic @ preserve magic
|
||||
mov r2, $key
|
||||
mov r4, $fp @ preserve fp
|
||||
mov r5, $magic @ preserve magic
|
||||
|
||||
bl AES_decrypt
|
||||
|
||||
|
||||
@@ -60,7 +60,12 @@
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
|
||||
static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c);
|
||||
static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c,
|
||||
int depth);
|
||||
static ASN1_STRING *int_d2i_ASN1_bytes(ASN1_STRING **a,
|
||||
const unsigned char **pp, long length,
|
||||
int Ptag, int Pclass, int depth,
|
||||
int *perr);
|
||||
/*
|
||||
* type is a 'bitmap' of acceptable string types.
|
||||
*/
|
||||
@@ -99,7 +104,7 @@ ASN1_STRING *d2i_ASN1_type_bytes(ASN1_STRING **a, const unsigned char **pp,
|
||||
ret = (*a);
|
||||
|
||||
if (len != 0) {
|
||||
s = (unsigned char *)OPENSSL_malloc((int)len + 1);
|
||||
s = OPENSSL_malloc((int)len + 1);
|
||||
if (s == NULL) {
|
||||
i = ERR_R_MALLOC_FAILURE;
|
||||
goto err;
|
||||
@@ -154,15 +159,38 @@ int i2d_ASN1_bytes(ASN1_STRING *a, unsigned char **pp, int tag, int xclass)
|
||||
return (r);
|
||||
}
|
||||
|
||||
/*
|
||||
* Maximum recursion depth of d2i_ASN1_bytes(): much more than should be
|
||||
* encountered in pratice.
|
||||
*/
|
||||
|
||||
#define ASN1_BYTES_MAXDEPTH 20
|
||||
|
||||
ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
|
||||
long length, int Ptag, int Pclass)
|
||||
{
|
||||
int err = 0;
|
||||
ASN1_STRING *s = int_d2i_ASN1_bytes(a, pp, length, Ptag, Pclass, 0, &err);
|
||||
if (err != 0)
|
||||
ASN1err(ASN1_F_D2I_ASN1_BYTES, err);
|
||||
return s;
|
||||
}
|
||||
|
||||
static ASN1_STRING *int_d2i_ASN1_bytes(ASN1_STRING **a,
|
||||
const unsigned char **pp, long length,
|
||||
int Ptag, int Pclass,
|
||||
int depth, int *perr)
|
||||
{
|
||||
ASN1_STRING *ret = NULL;
|
||||
const unsigned char *p;
|
||||
unsigned char *s;
|
||||
long len;
|
||||
int inf, tag, xclass;
|
||||
int i = 0;
|
||||
|
||||
if (depth > ASN1_BYTES_MAXDEPTH) {
|
||||
*perr = ASN1_R_NESTED_ASN1_STRING;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((a == NULL) || ((*a) == NULL)) {
|
||||
if ((ret = ASN1_STRING_new()) == NULL)
|
||||
@@ -173,18 +201,19 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
|
||||
p = *pp;
|
||||
inf = ASN1_get_object(&p, &len, &tag, &xclass, length);
|
||||
if (inf & 0x80) {
|
||||
i = ASN1_R_BAD_OBJECT_HEADER;
|
||||
*perr = ASN1_R_BAD_OBJECT_HEADER;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (tag != Ptag) {
|
||||
i = ASN1_R_WRONG_TAG;
|
||||
*perr = ASN1_R_WRONG_TAG;
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (inf & V_ASN1_CONSTRUCTED) {
|
||||
ASN1_const_CTX c;
|
||||
|
||||
c.error = 0;
|
||||
c.pp = pp;
|
||||
c.p = p;
|
||||
c.inf = inf;
|
||||
@@ -192,17 +221,18 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
|
||||
c.tag = Ptag;
|
||||
c.xclass = Pclass;
|
||||
c.max = (length == 0) ? 0 : (p + length);
|
||||
if (!asn1_collate_primitive(ret, &c))
|
||||
if (!asn1_collate_primitive(ret, &c, depth)) {
|
||||
*perr = c.error;
|
||||
goto err;
|
||||
else {
|
||||
} else {
|
||||
p = c.p;
|
||||
}
|
||||
} else {
|
||||
if (len != 0) {
|
||||
if ((ret->length < len) || (ret->data == NULL)) {
|
||||
s = (unsigned char *)OPENSSL_malloc((int)len + 1);
|
||||
s = OPENSSL_malloc((int)len + 1);
|
||||
if (s == NULL) {
|
||||
i = ERR_R_MALLOC_FAILURE;
|
||||
*perr = ERR_R_MALLOC_FAILURE;
|
||||
goto err;
|
||||
}
|
||||
if (ret->data != NULL)
|
||||
@@ -230,7 +260,6 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
|
||||
err:
|
||||
if ((ret != NULL) && ((a == NULL) || (*a != ret)))
|
||||
ASN1_STRING_free(ret);
|
||||
ASN1err(ASN1_F_D2I_ASN1_BYTES, i);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@@ -242,7 +271,8 @@ ASN1_STRING *d2i_ASN1_bytes(ASN1_STRING **a, const unsigned char **pp,
|
||||
* There have been a few bug fixes for this function from Paul Keogh
|
||||
* <paul.keogh@sse.ie>, many thanks to him
|
||||
*/
|
||||
static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c)
|
||||
static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c,
|
||||
int depth)
|
||||
{
|
||||
ASN1_STRING *os = NULL;
|
||||
BUF_MEM b;
|
||||
@@ -270,9 +300,8 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c)
|
||||
}
|
||||
|
||||
c->q = c->p;
|
||||
if (d2i_ASN1_bytes(&os, &c->p, c->max - c->p, c->tag, c->xclass)
|
||||
== NULL) {
|
||||
c->error = ERR_R_ASN1_LIB;
|
||||
if (int_d2i_ASN1_bytes(&os, &c->p, c->max - c->p, c->tag, c->xclass,
|
||||
depth + 1, &c->error) == NULL) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -297,7 +326,6 @@ static int asn1_collate_primitive(ASN1_STRING *a, ASN1_const_CTX *c)
|
||||
ASN1_STRING_free(os);
|
||||
return (1);
|
||||
err:
|
||||
ASN1err(ASN1_F_ASN1_COLLATE_PRIMITIVE, c->error);
|
||||
if (os != NULL)
|
||||
ASN1_STRING_free(os);
|
||||
if (b.data != NULL)
|
||||
|
||||
@@ -73,7 +73,7 @@ int i2d_ASN1_OBJECT(ASN1_OBJECT *a, unsigned char **pp)
|
||||
return (0);
|
||||
|
||||
objsize = ASN1_object_size(0, a->length, V_ASN1_OBJECT);
|
||||
if (pp == NULL)
|
||||
if (pp == NULL || objsize == -1)
|
||||
return objsize;
|
||||
|
||||
p = *pp;
|
||||
@@ -174,8 +174,12 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
|
||||
if (!tmp)
|
||||
goto err;
|
||||
}
|
||||
while (blsize--)
|
||||
tmp[i++] = (unsigned char)BN_div_word(bl, 0x80L);
|
||||
while (blsize--) {
|
||||
BN_ULONG t = BN_div_word(bl, 0x80L);
|
||||
if (t == (BN_ULONG)-1)
|
||||
goto err;
|
||||
tmp[i++] = (unsigned char)t;
|
||||
}
|
||||
} else {
|
||||
|
||||
for (;;) {
|
||||
|
||||
@@ -57,6 +57,7 @@
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/asn1_mac.h>
|
||||
|
||||
@@ -98,10 +99,14 @@ int i2d_ASN1_SET(STACK_OF(OPENSSL_BLOCK) *a, unsigned char **pp,
|
||||
|
||||
if (a == NULL)
|
||||
return (0);
|
||||
for (i = sk_OPENSSL_BLOCK_num(a) - 1; i >= 0; i--)
|
||||
for (i = sk_OPENSSL_BLOCK_num(a) - 1; i >= 0; i--) {
|
||||
int tmplen = i2d(sk_OPENSSL_BLOCK_value(a, i), NULL);
|
||||
if (tmplen > INT_MAX - ret)
|
||||
return -1;
|
||||
ret += i2d(sk_OPENSSL_BLOCK_value(a, i), NULL);
|
||||
}
|
||||
r = ASN1_object_size(1, ret, ex_tag);
|
||||
if (pp == NULL)
|
||||
if (pp == NULL || r == -1)
|
||||
return (r);
|
||||
|
||||
p = *pp;
|
||||
|
||||
@@ -337,7 +337,7 @@ static const signed char tag2nbyte[] = {
|
||||
-1, -1, -1, -1, -1, /* 5-9 */
|
||||
-1, -1, 0, -1, /* 10-13 */
|
||||
-1, -1, -1, -1, /* 15-17 */
|
||||
-1, 1, 1, /* 18-20 */
|
||||
1, 1, 1, /* 18-20 */
|
||||
-1, 1, 1, 1, /* 21-24 */
|
||||
-1, 1, -1, /* 25-27 */
|
||||
4, -1, 2 /* 28-30 */
|
||||
|
||||
@@ -250,6 +250,7 @@ int ASN1_STRING_TABLE_add(int nid,
|
||||
}
|
||||
tmp->flags = flags | STABLE_FLAGS_MALLOC;
|
||||
tmp->nid = nid;
|
||||
tmp->minsize = tmp->maxsize = -1;
|
||||
new_nid = 1;
|
||||
} else
|
||||
tmp->flags = (tmp->flags & STABLE_FLAGS_MALLOC) | flags;
|
||||
|
||||
@@ -93,7 +93,9 @@ static const EVP_PKEY_ASN1_METHOD *standard_methods[] = {
|
||||
&eckey_asn1_meth,
|
||||
#endif
|
||||
&hmac_asn1_meth,
|
||||
#ifndef OPENSSL_NO_CMAC
|
||||
&cmac_asn1_meth,
|
||||
#endif
|
||||
#ifndef OPENSSL_NO_DH
|
||||
&dhx_asn1_meth
|
||||
#endif
|
||||
|
||||
@@ -256,26 +256,30 @@ static void asn1_put_length(unsigned char **pp, int length)
|
||||
|
||||
int ASN1_object_size(int constructed, int length, int tag)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = length;
|
||||
ret++;
|
||||
int ret = 1;
|
||||
if (length < 0)
|
||||
return -1;
|
||||
if (tag >= 31) {
|
||||
while (tag > 0) {
|
||||
tag >>= 7;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
if (constructed == 2)
|
||||
return ret + 3;
|
||||
ret++;
|
||||
if (length > 127) {
|
||||
while (length > 0) {
|
||||
length >>= 8;
|
||||
ret++;
|
||||
if (constructed == 2) {
|
||||
ret += 3;
|
||||
} else {
|
||||
ret++;
|
||||
if (length > 127) {
|
||||
int tmplen = length;
|
||||
while (tmplen > 0) {
|
||||
tmplen >>= 8;
|
||||
ret++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return (ret);
|
||||
if (ret >= INT_MAX - length)
|
||||
return -1;
|
||||
return ret + length;
|
||||
}
|
||||
|
||||
static int _asn1_Finish(ASN1_const_CTX *c)
|
||||
@@ -324,7 +328,7 @@ int asn1_GetSequence(ASN1_const_CTX *c, long *length)
|
||||
return (0);
|
||||
}
|
||||
if (c->inf == (1 | V_ASN1_CONSTRUCTED))
|
||||
c->slen = *length + *(c->pp) - c->p;
|
||||
c->slen = *length;
|
||||
c->eos = 0;
|
||||
return (1);
|
||||
}
|
||||
@@ -366,7 +370,7 @@ int ASN1_STRING_set(ASN1_STRING *str, const void *_data, int len)
|
||||
else
|
||||
len = strlen(data);
|
||||
}
|
||||
if ((str->length < len) || (str->data == NULL)) {
|
||||
if ((str->length <= len) || (str->data == NULL)) {
|
||||
c = str->data;
|
||||
if (c == NULL)
|
||||
str->data = OPENSSL_malloc(len + 1);
|
||||
|
||||
@@ -289,7 +289,7 @@ int SMIME_write_ASN1(BIO *bio, ASN1_VALUE *val, BIO *data, int flags,
|
||||
if ((flags & SMIME_DETACHED) && data) {
|
||||
/* We want multipart/signed */
|
||||
/* Generate a random boundary */
|
||||
if (RAND_pseudo_bytes((unsigned char *)bound, 32) < 0)
|
||||
if (RAND_bytes((unsigned char *)bound, 32) <= 0)
|
||||
return 0;
|
||||
for (i = 0; i < 32; i++) {
|
||||
c = bound[i] & 0xf;
|
||||
@@ -623,6 +623,8 @@ static int multi_split(BIO *bio, char *bound, STACK_OF(BIO) **ret)
|
||||
if (bpart)
|
||||
sk_BIO_push(parts, bpart);
|
||||
bpart = BIO_new(BIO_s_mem());
|
||||
if (bpart == NULL)
|
||||
return 1;
|
||||
BIO_set_mem_eof_return(bpart, 0);
|
||||
} else if (eol)
|
||||
BIO_write(bpart, "\r\n", 2);
|
||||
|
||||
@@ -170,10 +170,12 @@ static int asn1_bio_init(BIO_ASN1_BUF_CTX *ctx, int size)
|
||||
ctx->copylen = 0;
|
||||
ctx->asn1_class = V_ASN1_UNIVERSAL;
|
||||
ctx->asn1_tag = V_ASN1_OCTET_STRING;
|
||||
ctx->ex_buf = 0;
|
||||
ctx->ex_pos = 0;
|
||||
ctx->ex_buf = NULL;
|
||||
ctx->ex_len = 0;
|
||||
ctx->ex_pos = 0;
|
||||
ctx->state = ASN1_STATE_START;
|
||||
ctx->prefix = ctx->prefix_free = ctx->suffix = ctx->suffix_free = NULL;
|
||||
ctx->ex_arg = NULL;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ BIO *BIO_new_NDEF(BIO *out, ASN1_VALUE *val, const ASN1_ITEM *it)
|
||||
ndef_aux->ndef_bio = sarg.ndef_bio;
|
||||
ndef_aux->boundary = sarg.boundary;
|
||||
ndef_aux->out = out;
|
||||
ndef_aux->derbuf = NULL;
|
||||
|
||||
BIO_ctrl(asn_bio, BIO_C_SET_EX_ARG, 0, ndef_aux);
|
||||
|
||||
|
||||
@@ -67,17 +67,19 @@ $arr[ord("?")] |= $PSTRING_CHAR;
|
||||
# Now generate the C code
|
||||
|
||||
print <<EOF;
|
||||
/* Auto generated with chartype.pl script.
|
||||
* Mask of various character properties
|
||||
/*
|
||||
* Auto generated with chartype.pl script. Mask of various character
|
||||
* properties
|
||||
*/
|
||||
|
||||
static unsigned char char_type[] = {
|
||||
static const unsigned char char_type[] = {
|
||||
EOF
|
||||
|
||||
print " ";
|
||||
for($i = 0; $i < 128; $i++) {
|
||||
print("\n") if($i && (($i % 16) == 0));
|
||||
printf("%2d", $arr[$i]);
|
||||
print("\n ") if($i && (($i % 16) == 0));
|
||||
printf(" %d", $arr[$i]);
|
||||
print(",") if ($i != 127);
|
||||
}
|
||||
print("\n};\n\n");
|
||||
print("\n};\n");
|
||||
|
||||
@@ -97,15 +97,17 @@ EVP_PKEY *d2i_PrivateKey(int type, EVP_PKEY **a, const unsigned char **pp,
|
||||
if (!ret->ameth->old_priv_decode ||
|
||||
!ret->ameth->old_priv_decode(ret, &p, length)) {
|
||||
if (ret->ameth->priv_decode) {
|
||||
EVP_PKEY *tmp;
|
||||
PKCS8_PRIV_KEY_INFO *p8 = NULL;
|
||||
p8 = d2i_PKCS8_PRIV_KEY_INFO(NULL, &p, length);
|
||||
if (!p8)
|
||||
goto err;
|
||||
EVP_PKEY_free(ret);
|
||||
ret = EVP_PKCS82PKEY(p8);
|
||||
tmp = EVP_PKCS82PKEY(p8);
|
||||
PKCS8_PRIV_KEY_INFO_free(p8);
|
||||
if (ret == NULL)
|
||||
if (tmp == NULL)
|
||||
goto err;
|
||||
EVP_PKEY_free(ret);
|
||||
ret = tmp;
|
||||
} else {
|
||||
ASN1err(ASN1_F_D2I_PRIVATEKEY, ERR_R_ASN1_LIB);
|
||||
goto err;
|
||||
|
||||
@@ -160,8 +160,6 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
|
||||
i * 2);
|
||||
if (sp == NULL) {
|
||||
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ERR_R_MALLOC_FAILURE);
|
||||
if (s != NULL)
|
||||
OPENSSL_free(s);
|
||||
goto err;
|
||||
}
|
||||
s = sp;
|
||||
@@ -199,5 +197,7 @@ int a2i_ASN1_ENUMERATED(BIO *bp, ASN1_ENUMERATED *bs, char *buf, int size)
|
||||
err_sl:
|
||||
ASN1err(ASN1_F_A2I_ASN1_ENUMERATED, ASN1_R_SHORT_LINE);
|
||||
}
|
||||
if (ret != 1)
|
||||
OPENSSL_free(s);
|
||||
return (ret);
|
||||
}
|
||||
@@ -172,8 +172,6 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
|
||||
sp = OPENSSL_realloc_clean(s, slen, num + i * 2);
|
||||
if (sp == NULL) {
|
||||
ASN1err(ASN1_F_A2I_ASN1_INTEGER, ERR_R_MALLOC_FAILURE);
|
||||
if (s != NULL)
|
||||
OPENSSL_free(s);
|
||||
goto err;
|
||||
}
|
||||
s = sp;
|
||||
@@ -211,5 +209,7 @@ int a2i_ASN1_INTEGER(BIO *bp, ASN1_INTEGER *bs, char *buf, int size)
|
||||
err_sl:
|
||||
ASN1err(ASN1_F_A2I_ASN1_INTEGER, ASN1_R_SHORT_LINE);
|
||||
}
|
||||
if (ret != 1)
|
||||
OPENSSL_free(s);
|
||||
return (ret);
|
||||
}
|
||||
@@ -166,8 +166,6 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
|
||||
i * 2);
|
||||
if (sp == NULL) {
|
||||
ASN1err(ASN1_F_A2I_ASN1_STRING, ERR_R_MALLOC_FAILURE);
|
||||
if (s != NULL)
|
||||
OPENSSL_free(s);
|
||||
goto err;
|
||||
}
|
||||
s = sp;
|
||||
@@ -205,5 +203,7 @@ int a2i_ASN1_STRING(BIO *bp, ASN1_STRING *bs, char *buf, int size)
|
||||
err_sl:
|
||||
ASN1err(ASN1_F_A2I_ASN1_STRING, ASN1_R_SHORT_LINE);
|
||||
}
|
||||
if (ret != 1)
|
||||
OPENSSL_free(s);
|
||||
return (ret);
|
||||
}
|
||||
@@ -69,10 +69,13 @@ int i2d_PrivateKey(EVP_PKEY *a, unsigned char **pp)
|
||||
}
|
||||
if (a->ameth && a->ameth->priv_encode) {
|
||||
PKCS8_PRIV_KEY_INFO *p8 = EVP_PKEY2PKCS8(a);
|
||||
int ret = i2d_PKCS8_PRIV_KEY_INFO(p8, pp);
|
||||
PKCS8_PRIV_KEY_INFO_free(p8);
|
||||
int ret = 0;
|
||||
if (p8 != NULL) {
|
||||
ret = i2d_PKCS8_PRIV_KEY_INFO(p8, pp);
|
||||
PKCS8_PRIV_KEY_INFO_free(p8);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
ASN1err(ASN1_F_I2D_PRIVATEKEY, ASN1_R_UNSUPPORTED_PUBLIC_KEY_TYPE);
|
||||
return (-1);
|
||||
return -1;
|
||||
}
|
||||
@@ -101,7 +101,7 @@ int PKCS5_pbe_set0_algor(X509_ALGOR *algor, int alg, int iter,
|
||||
sstr = ASN1_STRING_data(pbe->salt);
|
||||
if (salt)
|
||||
memcpy(sstr, salt, saltlen);
|
||||
else if (RAND_pseudo_bytes(sstr, saltlen) < 0)
|
||||
else if (RAND_bytes(sstr, saltlen) <= 0)
|
||||
goto err;
|
||||
|
||||
if (!ASN1_item_pack(pbe, ASN1_ITEM_rptr(PBEPARAM), &pbe_str)) {
|
||||
|
||||
@@ -120,7 +120,7 @@ X509_ALGOR *PKCS5_pbe2_set_iv(const EVP_CIPHER *cipher, int iter,
|
||||
if (EVP_CIPHER_iv_length(cipher)) {
|
||||
if (aiv)
|
||||
memcpy(iv, aiv, EVP_CIPHER_iv_length(cipher));
|
||||
else if (RAND_pseudo_bytes(iv, EVP_CIPHER_iv_length(cipher)) < 0)
|
||||
else if (RAND_bytes(iv, EVP_CIPHER_iv_length(cipher)) <= 0)
|
||||
goto err;
|
||||
}
|
||||
|
||||
@@ -225,7 +225,7 @@ X509_ALGOR *PKCS5_pbkdf2_set(int iter, unsigned char *salt, int saltlen,
|
||||
|
||||
if (salt)
|
||||
memcpy(osalt->data, salt, saltlen);
|
||||
else if (RAND_pseudo_bytes(osalt->data, saltlen) < 0)
|
||||
else if (RAND_bytes(osalt->data, saltlen) <= 0)
|
||||
goto merr;
|
||||
|
||||
if (iter <= 0)
|
||||
|
||||
@@ -196,6 +196,7 @@ int X509_REQ_print_ex(BIO *bp, X509_REQ *x, unsigned long nmflags,
|
||||
if (BIO_puts(bp, ":") <= 0)
|
||||
goto err;
|
||||
if ((type == V_ASN1_PRINTABLESTRING) ||
|
||||
(type == V_ASN1_UTF8STRING) ||
|
||||
(type == V_ASN1_T61STRING) ||
|
||||
(type == V_ASN1_IA5STRING)) {
|
||||
if (BIO_write(bp, (char *)bs->data, bs->length)
|
||||
|
||||
@@ -400,7 +400,9 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
if (tt->flags & ASN1_TFLG_ADB_MASK) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
seqtt = asn1_do_adb(pval, tt, 0);
|
||||
if (seqtt == NULL)
|
||||
continue;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
ASN1_template_free(pseqval, seqtt);
|
||||
}
|
||||
@@ -411,7 +413,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
if (!seqtt)
|
||||
if (seqtt == NULL)
|
||||
goto err;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
/* Have we ran out of data? */
|
||||
@@ -476,7 +478,7 @@ int ASN1_item_ex_d2i(ASN1_VALUE **pval, const unsigned char **in, long len,
|
||||
for (; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
if (!seqtt)
|
||||
if (seqtt == NULL)
|
||||
goto err;
|
||||
if (seqtt->flags & ASN1_TFLG_OPTIONAL) {
|
||||
ASN1_VALUE **pseqval;
|
||||
|
||||
@@ -59,6 +59,7 @@
|
||||
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <limits.h>
|
||||
#include "cryptlib.h"
|
||||
#include <openssl/asn1.h>
|
||||
#include <openssl/asn1t.h>
|
||||
@@ -216,17 +217,19 @@ int ASN1_item_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
for (i = 0, tt = it->templates; i < it->tcount; tt++, i++) {
|
||||
const ASN1_TEMPLATE *seqtt;
|
||||
ASN1_VALUE **pseqval;
|
||||
int tmplen;
|
||||
seqtt = asn1_do_adb(pval, tt, 1);
|
||||
if (!seqtt)
|
||||
return 0;
|
||||
pseqval = asn1_get_field_ptr(pval, seqtt);
|
||||
/* FIXME: check for errors in enhanced version */
|
||||
seqcontlen += asn1_template_ex_i2d(pseqval, NULL, seqtt,
|
||||
-1, aclass);
|
||||
tmplen = asn1_template_ex_i2d(pseqval, NULL, seqtt, -1, aclass);
|
||||
if (tmplen == -1 || (tmplen > INT_MAX - seqcontlen))
|
||||
return -1;
|
||||
seqcontlen += tmplen;
|
||||
}
|
||||
|
||||
seqlen = ASN1_object_size(ndef, seqcontlen, tag);
|
||||
if (!out)
|
||||
if (!out || seqlen == -1)
|
||||
return seqlen;
|
||||
/* Output SEQUENCE header */
|
||||
ASN1_put_object(out, ndef, seqcontlen, tag, aclass);
|
||||
@@ -339,19 +342,24 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
/* Determine total length of items */
|
||||
skcontlen = 0;
|
||||
for (i = 0; i < sk_ASN1_VALUE_num(sk); i++) {
|
||||
int tmplen;
|
||||
skitem = sk_ASN1_VALUE_value(sk, i);
|
||||
skcontlen += ASN1_item_ex_i2d(&skitem, NULL,
|
||||
ASN1_ITEM_ptr(tt->item),
|
||||
-1, iclass);
|
||||
tmplen = ASN1_item_ex_i2d(&skitem, NULL, ASN1_ITEM_ptr(tt->item),
|
||||
-1, iclass);
|
||||
if (tmplen == -1 || (skcontlen > INT_MAX - tmplen))
|
||||
return -1;
|
||||
skcontlen += tmplen;
|
||||
}
|
||||
sklen = ASN1_object_size(ndef, skcontlen, sktag);
|
||||
if (sklen == -1)
|
||||
return -1;
|
||||
/* If EXPLICIT need length of surrounding tag */
|
||||
if (flags & ASN1_TFLG_EXPTAG)
|
||||
ret = ASN1_object_size(ndef, sklen, ttag);
|
||||
else
|
||||
ret = sklen;
|
||||
|
||||
if (!out)
|
||||
if (!out || ret == -1)
|
||||
return ret;
|
||||
|
||||
/* Now encode this lot... */
|
||||
@@ -380,7 +388,7 @@ static int asn1_template_ex_i2d(ASN1_VALUE **pval, unsigned char **out,
|
||||
return 0;
|
||||
/* Find length of EXPLICIT tag */
|
||||
ret = ASN1_object_size(ndef, i, ttag);
|
||||
if (out) {
|
||||
if (out && ret != -1) {
|
||||
/* Output tag and item */
|
||||
ASN1_put_object(out, ndef, i, ttag, tclass);
|
||||
ASN1_item_ex_i2d(pval, out, ASN1_ITEM_ptr(tt->item), -1, iclass);
|
||||
|
||||
@@ -204,7 +204,8 @@ static int asn1_item_print_ctx(BIO *out, ASN1_VALUE **fld, int indent,
|
||||
} else
|
||||
asn1_cb = 0;
|
||||
|
||||
if (*fld == NULL) {
|
||||
if (((it->itype != ASN1_ITYPE_PRIMITIVE)
|
||||
|| (it->utype != V_ASN1_BOOLEAN)) && *fld == NULL) {
|
||||
if (pctx->flags & ASN1_PCTX_FLAGS_SHOW_ABSENT) {
|
||||
if (!nohdr && !asn1_print_fsname(out, indent, fname, sname, pctx))
|
||||
return 0;
|
||||
@@ -446,6 +447,8 @@ static int asn1_print_integer_ctx(BIO *out, ASN1_INTEGER *str,
|
||||
char *s;
|
||||
int ret = 1;
|
||||
s = i2s_ASN1_INTEGER(NULL, str);
|
||||
if (s == NULL)
|
||||
return 0;
|
||||
if (BIO_puts(out, s) <= 0)
|
||||
ret = 0;
|
||||
OPENSSL_free(s);
|
||||
@@ -496,11 +499,16 @@ static int asn1_primitive_print(BIO *out, ASN1_VALUE **fld,
|
||||
return 0;
|
||||
if (pf && pf->prim_print)
|
||||
return pf->prim_print(out, fld, it, indent, pctx);
|
||||
str = (ASN1_STRING *)*fld;
|
||||
if (it->itype == ASN1_ITYPE_MSTRING)
|
||||
if (it->itype == ASN1_ITYPE_MSTRING) {
|
||||
str = (ASN1_STRING *)*fld;
|
||||
utype = str->type & ~V_ASN1_NEG;
|
||||
else
|
||||
} else {
|
||||
utype = it->utype;
|
||||
if (utype == V_ASN1_BOOLEAN)
|
||||
str = NULL;
|
||||
else
|
||||
str = (ASN1_STRING *)*fld;
|
||||
}
|
||||
if (utype == V_ASN1_ANY) {
|
||||
ASN1_TYPE *atype = (ASN1_TYPE *)*fld;
|
||||
utype = atype->type;
|
||||
|
||||
@@ -234,7 +234,7 @@ const ASN1_TEMPLATE *asn1_do_adb(ASN1_VALUE **pval, const ASN1_TEMPLATE *tt,
|
||||
sfld = offset2ptr(*pval, adb->offset);
|
||||
|
||||
/* Check if NULL */
|
||||
if (!sfld) {
|
||||
if (*sfld == NULL) {
|
||||
if (!adb->null_tt)
|
||||
goto err;
|
||||
return adb->null_tt;
|
||||
|
||||
@@ -78,6 +78,8 @@ static int bn_i2c(ASN1_VALUE **pval, unsigned char *cont, int *putype,
|
||||
const ASN1_ITEM *it);
|
||||
static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
int utype, char *free_cont, const ASN1_ITEM *it);
|
||||
static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx);
|
||||
|
||||
static ASN1_PRIMITIVE_FUNCS bignum_pf = {
|
||||
NULL, 0,
|
||||
@@ -85,7 +87,8 @@ static ASN1_PRIMITIVE_FUNCS bignum_pf = {
|
||||
bn_free,
|
||||
0,
|
||||
bn_c2i,
|
||||
bn_i2c
|
||||
bn_i2c,
|
||||
bn_print
|
||||
};
|
||||
|
||||
ASN1_ITEM_start(BIGNUM)
|
||||
@@ -151,3 +154,13 @@ static int bn_c2i(ASN1_VALUE **pval, const unsigned char *cont, int len,
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int bn_print(BIO *out, ASN1_VALUE **pval, const ASN1_ITEM *it,
|
||||
int indent, const ASN1_PCTX *pctx)
|
||||
{
|
||||
if (!BN_print(out, *(BIGNUM **)pval))
|
||||
return 0;
|
||||
if (BIO_puts(out, "\n") <= 0)
|
||||
return 0;
|
||||
return 1;
|
||||
}
|
||||
@@ -199,10 +199,8 @@ static int x509_name_ex_d2i(ASN1_VALUE **val,
|
||||
int i, j, ret;
|
||||
STACK_OF(X509_NAME_ENTRY) *entries;
|
||||
X509_NAME_ENTRY *entry;
|
||||
if (len > X509_NAME_MAX) {
|
||||
ASN1err(ASN1_F_X509_NAME_EX_D2I, ASN1_R_TOO_LONG);
|
||||
return 0;
|
||||
}
|
||||
if (len > X509_NAME_MAX)
|
||||
len = X509_NAME_MAX;
|
||||
q = p;
|
||||
|
||||
/* Get internal representation of Name */
|
||||
|
||||
Loaded 100 of 855 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user