From owner-svn-src-vendor@freebsd.org Mon Mar 30 16:25:39 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 55BC92A786E; Mon, 30 Mar 2020 16:25:39 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48rd9X5vpHz4Hx8; Mon, 30 Mar 2020 16:25:34 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B18A31F142; Mon, 30 Mar 2020 16:20:05 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02UGK5cl028792; Mon, 30 Mar 2020 16:20:05 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02UGK4hp028791; Mon, 30 Mar 2020 16:20:04 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <202003301620.02UGK4hp028791@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Mon, 30 Mar 2020 16:20:04 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359442 - vendor/NetBSD/bmake/dist X-SVN-Group: vendor X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: vendor/NetBSD/bmake/dist X-SVN-Commit-Revision: 359442 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 30 Mar 2020 16:25:39 -0000 Author: kevans Date: Mon Mar 30 16:20:04 2020 New Revision: 359442 URL: https://svnweb.freebsd.org/changeset/base/359442 Log: bmake: import -fno-common fix build back from upstream sjg@ committed the local patch previously committed upstream; pull it in to vendor/ to ease any potential stress of future imports. Modified: vendor/NetBSD/bmake/dist/main.c vendor/NetBSD/bmake/dist/make.h Modified: vendor/NetBSD/bmake/dist/main.c ============================================================================== --- vendor/NetBSD/bmake/dist/main.c Mon Mar 30 16:04:25 2020 (r359441) +++ vendor/NetBSD/bmake/dist/main.c Mon Mar 30 16:20:04 2020 (r359442) @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.273 2017/10/28 21:54:54 sjg Exp $ */ +/* $NetBSD: main.c,v 1.274 2020/03/30 02:41:06 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.273 2017/10/28 21:54:54 sjg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.274 2020/03/30 02:41:06 sjg Exp $"; #else #include #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993 #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.273 2017/10/28 21:54:54 sjg Exp $"); +__RCSID("$NetBSD: main.c,v 1.274 2020/03/30 02:41:06 sjg Exp $"); #endif #endif /* not lint */ #endif @@ -198,6 +198,8 @@ char *progname; /* the program name */ char *makeDependfile; pid_t myPid; int makelevel; + +FILE *debug_file; Boolean forceJobs = FALSE; Modified: vendor/NetBSD/bmake/dist/make.h ============================================================================== --- vendor/NetBSD/bmake/dist/make.h Mon Mar 30 16:04:25 2020 (r359441) +++ vendor/NetBSD/bmake/dist/make.h Mon Mar 30 16:20:04 2020 (r359442) @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.104 2018/02/12 21:38:09 sjg Exp $ */ +/* $NetBSD: make.h,v 1.105 2020/03/30 02:41:06 sjg Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -464,7 +464,7 @@ extern pid_t myPid; * There is one bit per module. It is up to the module what debug * information to print. */ -FILE *debug_file; /* Output written here - default stdout */ +extern FILE *debug_file; /* Output written here - default stdout */ extern int debug; #define DEBUG_ARCH 0x00001 #define DEBUG_COND 0x00002 From owner-svn-src-vendor@freebsd.org Tue Mar 31 15:25:36 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 98D7B260BCD; Tue, 31 Mar 2020 15:25:36 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48sCnr15JWz3R8j; Tue, 31 Mar 2020 15:25:36 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4C69DBFE9; Tue, 31 Mar 2020 15:25:28 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02VFPS9v076318; Tue, 31 Mar 2020 15:25:28 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02VFPNkW076294; Tue, 31 Mar 2020 15:25:23 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <202003311525.02VFPNkW076294@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Tue, 31 Mar 2020 15:25:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359482 - in vendor-crypto/openssl/dist: . apps crypto crypto/bn crypto/conf crypto/err crypto/pkcs12 crypto/ts crypto/x509 crypto/x509v3 doc/man3 include/openssl ssl ssl/record X-SVN-Group: vendor-crypto X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: in vendor-crypto/openssl/dist: . apps crypto crypto/bn crypto/conf crypto/err crypto/pkcs12 crypto/ts crypto/x509 crypto/x509v3 doc/man3 include/openssl ssl ssl/record X-SVN-Commit-Revision: 359482 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 15:25:36 -0000 Author: jkim Date: Tue Mar 31 15:25:23 2020 New Revision: 359482 URL: https://svnweb.freebsd.org/changeset/base/359482 Log: Import OpenSSL 1.1.1f. Modified: vendor-crypto/openssl/dist/CHANGES vendor-crypto/openssl/dist/NEWS vendor-crypto/openssl/dist/README vendor-crypto/openssl/dist/apps/rehash.c vendor-crypto/openssl/dist/apps/s_server.c vendor-crypto/openssl/dist/crypto/bn/bn_local.h vendor-crypto/openssl/dist/crypto/bn/bn_prime.c vendor-crypto/openssl/dist/crypto/conf/conf_lib.c vendor-crypto/openssl/dist/crypto/err/openssl.txt vendor-crypto/openssl/dist/crypto/ex_data.c vendor-crypto/openssl/dist/crypto/pkcs12/p12_crt.c vendor-crypto/openssl/dist/crypto/ts/ts_rsp_sign.c vendor-crypto/openssl/dist/crypto/ts/ts_rsp_verify.c vendor-crypto/openssl/dist/crypto/x509/x509_cmp.c vendor-crypto/openssl/dist/crypto/x509/x509_trs.c vendor-crypto/openssl/dist/crypto/x509/x509_vfy.c vendor-crypto/openssl/dist/crypto/x509/x_all.c vendor-crypto/openssl/dist/crypto/x509/x_crl.c vendor-crypto/openssl/dist/crypto/x509v3/v3_purp.c vendor-crypto/openssl/dist/doc/man3/BN_generate_prime.pod vendor-crypto/openssl/dist/doc/man3/SSL_get_error.pod vendor-crypto/openssl/dist/doc/man3/X509_get_extension_flags.pod vendor-crypto/openssl/dist/include/openssl/opensslv.h vendor-crypto/openssl/dist/include/openssl/sslerr.h vendor-crypto/openssl/dist/ssl/record/rec_layer_s3.c vendor-crypto/openssl/dist/ssl/ssl_err.c Modified: vendor-crypto/openssl/dist/CHANGES ============================================================================== --- vendor-crypto/openssl/dist/CHANGES Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/CHANGES Tue Mar 31 15:25:23 2020 (r359482) @@ -7,6 +7,24 @@ https://github.com/openssl/openssl/commits/ and pick the appropriate release branch. + Changes between 1.1.1e and 1.1.1f [31 Mar 2020] + + *) Revert the change of EOF detection while reading in libssl to avoid + regressions in applications depending on the current way of reporting + the EOF. As the existing method is not fully accurate the change to + reporting the EOF via SSL_ERROR_SSL is kept on the current development + branch and will be present in the 3.0 release. + [Tomas Mraz] + + *) Revised BN_generate_prime_ex to not avoid factors 3..17863 in p-1 + when primes for RSA keys are computed. + Since we previously always generated primes == 2 (mod 3) for RSA keys, + the 2-prime and 3-prime RSA modules were easy to distinguish, since + N = p*q = 1 (mod 3), but N = p*q*r = 2 (mod 3). Therefore fingerprinting + 2-prime vs. 3-prime RSA keys was possible by computing N mod 3. + This avoids possible fingerprinting of newly generated RSA modules. + [Bernd Edlinger] + Changes between 1.1.1d and 1.1.1e [17 Mar 2020] *) Properly detect EOF while reading in libssl. Previously if we hit an EOF while reading in libssl then we would report an error back to the Modified: vendor-crypto/openssl/dist/NEWS ============================================================================== --- vendor-crypto/openssl/dist/NEWS Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/NEWS Tue Mar 31 15:25:23 2020 (r359482) @@ -5,10 +5,16 @@ 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.1.1e and OpenSSL 1.1.1f [31 Mar 2020] + + o Revert the unexpected EOF reporting via SSL_ERROR_SSL + Major changes between OpenSSL 1.1.1d and OpenSSL 1.1.1e [17 Mar 2020] o Fixed an overflow bug in the x64_64 Montgomery squaring procedure used in exponentiation with 512-bit moduli (CVE-2019-1551) + o Properly detect unexpected EOF while reading in libssl and report + it via SSL_ERROR_SSL Major changes between OpenSSL 1.1.1c and OpenSSL 1.1.1d [10 Sep 2019] Modified: vendor-crypto/openssl/dist/README ============================================================================== --- vendor-crypto/openssl/dist/README Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/README Tue Mar 31 15:25:23 2020 (r359482) @@ -1,7 +1,7 @@ - OpenSSL 1.1.1e 17 Mar 2020 + OpenSSL 1.1.1f 31 Mar 2020 - Copyright (c) 1998-2019 The OpenSSL Project + Copyright (c) 1998-2020 The OpenSSL Project Copyright (c) 1995-1998 Eric A. Young, Tim J. Hudson All rights reserved. Modified: vendor-crypto/openssl/dist/apps/rehash.c ============================================================================== --- vendor-crypto/openssl/dist/apps/rehash.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/apps/rehash.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 2015-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2015-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2013-2014 Timo Teräs * * Licensed under the OpenSSL license (the "License"). You may not use @@ -274,11 +274,19 @@ static int do_file(const char *filename, const char *f if (x->x509 != NULL) { type = TYPE_CERT; name = X509_get_subject_name(x->x509); - X509_digest(x->x509, evpmd, digest, NULL); + if (!X509_digest(x->x509, evpmd, digest, NULL)) { + BIO_printf(bio_err, "out of memory\n"); + ++errs; + goto end; + } } else if (x->crl != NULL) { type = TYPE_CRL; name = X509_CRL_get_issuer(x->crl); - X509_CRL_digest(x->crl, evpmd, digest, NULL); + if (!X509_CRL_digest(x->crl, evpmd, digest, NULL)) { + BIO_printf(bio_err, "out of memory\n"); + ++errs; + goto end; + } } else { ++errs; goto end; Modified: vendor-crypto/openssl/dist/apps/s_server.c ============================================================================== --- vendor-crypto/openssl/dist/apps/s_server.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/apps/s_server.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 The OpenSSL Project Authors. All Rights Reserved. * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved * Copyright 2005 Nokia. All rights reserved. * @@ -1904,7 +1904,7 @@ int s_server_main(int argc, char *argv[]) BIO_printf(bio_s_out, "Setting secondary ctx parameters\n"); if (sdebug) - ssl_ctx_security_debug(ctx, sdebug); + ssl_ctx_security_debug(ctx2, sdebug); if (session_id_prefix) { if (strlen(session_id_prefix) >= 32) Modified: vendor-crypto/openssl/dist/crypto/bn/bn_local.h ============================================================================== --- vendor-crypto/openssl/dist/crypto/bn/bn_local.h Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/bn/bn_local.h Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -653,9 +653,6 @@ int bn_mul_mont(BN_ULONG *rp, const BN_ULONG *ap, cons BIGNUM *int_bn_mod_inverse(BIGNUM *in, const BIGNUM *a, const BIGNUM *n, BN_CTX *ctx, int *noinv); - -int bn_probable_prime_dh(BIGNUM *rnd, int bits, - const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx); static ossl_inline BIGNUM *bn_expand(BIGNUM *a, int bits) { Modified: vendor-crypto/openssl/dist/crypto/bn/bn_prime.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/bn/bn_prime.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/bn/bn_prime.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -22,11 +22,13 @@ static int witness(BIGNUM *w, const BIGNUM *a, const BIGNUM *a1, const BIGNUM *a1_odd, int k, BN_CTX *ctx, BN_MONT_CTX *mont); -static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods); -static int probable_prime_dh_safe(BIGNUM *rnd, int bits, - const BIGNUM *add, const BIGNUM *rem, - BN_CTX *ctx); +static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods); +static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, + const BIGNUM *add, const BIGNUM *rem, + BN_CTX *ctx); +#define square(x) ((BN_ULONG)(x) * (BN_ULONG)(x)) + int BN_GENCB_call(BN_GENCB *cb, int a, int b) { /* No callback means continue */ @@ -87,16 +89,11 @@ int BN_generate_prime_ex(BIGNUM *ret, int bits, int sa loop: /* make a random number and set the top and bottom bits */ if (add == NULL) { - if (!probable_prime(ret, bits, mods)) + if (!probable_prime(ret, bits, safe, mods)) goto err; } else { - if (safe) { - if (!probable_prime_dh_safe(ret, bits, add, rem, ctx)) - goto err; - } else { - if (!bn_probable_prime_dh(ret, bits, add, rem, ctx)) - goto err; - } + if (!probable_prime_dh(ret, bits, safe, mods, add, rem, ctx)) + goto err; } if (!BN_GENCB_call(cb, 0, c1++)) @@ -272,17 +269,18 @@ static int witness(BIGNUM *w, const BIGNUM *a, const B return 1; } -static int probable_prime(BIGNUM *rnd, int bits, prime_t *mods) +static int probable_prime(BIGNUM *rnd, int bits, int safe, prime_t *mods) { int i; BN_ULONG delta; BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; - char is_single_word = bits <= BN_BITS2; again: /* TODO: Not all primes are private */ if (!BN_priv_rand(rnd, bits, BN_RAND_TOP_TWO, BN_RAND_BOTTOM_ODD)) return 0; + if (safe && !BN_set_bit(rnd, 1)) + return 0; /* we now have a random number 'rnd' to test. */ for (i = 1; i < NUMPRIMES; i++) { BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); @@ -290,62 +288,26 @@ static int probable_prime(BIGNUM *rnd, int bits, prime return 0; mods[i] = (prime_t) mod; } - /* - * If bits is so small that it fits into a single word then we - * additionally don't want to exceed that many bits. - */ - if (is_single_word) { - BN_ULONG size_limit; - - if (bits == BN_BITS2) { - /* - * Shifting by this much has undefined behaviour so we do it a - * different way - */ - size_limit = ~((BN_ULONG)0) - BN_get_word(rnd); - } else { - size_limit = (((BN_ULONG)1) << bits) - BN_get_word(rnd) - 1; - } - if (size_limit < maxdelta) - maxdelta = size_limit; - } delta = 0; loop: - if (is_single_word) { - BN_ULONG rnd_word = BN_get_word(rnd); - - /*- - * In the case that the candidate prime is a single word then - * we check that: - * 1) It's greater than primes[i] because we shouldn't reject - * 3 as being a prime number because it's a multiple of - * three. - * 2) That it's not a multiple of a known prime. We don't - * check that rnd-1 is also coprime to all the known - * primes because there aren't many small primes where - * that's true. + for (i = 1; i < NUMPRIMES; i++) { + /* + * check that rnd is a prime and also that + * gcd(rnd-1,primes) == 1 (except for 2) + * do the second check only if we are interested in safe primes + * in the case that the candidate prime is a single word then + * we check only the primes up to sqrt(rnd) */ - for (i = 1; i < NUMPRIMES && primes[i] < rnd_word; i++) { - if ((mods[i] + delta) % primes[i] == 0) { - delta += 2; - if (delta > maxdelta) - goto again; - goto loop; - } + if (bits <= 31 && delta <= 0x7fffffff + && square(primes[i]) > BN_get_word(rnd) + delta) + break; + if (safe ? (mods[i] + delta) % primes[i] <= 1 + : (mods[i] + delta) % primes[i] == 0) { + delta += safe ? 4 : 2; + if (delta > maxdelta) + goto again; + goto loop; } - } else { - for (i = 1; i < NUMPRIMES; i++) { - /* - * check that rnd is not a prime and also that gcd(rnd-1,primes) - * == 1 (except for 2) - */ - if (((mods[i] + delta) % primes[i]) <= 1) { - delta += 2; - if (delta > maxdelta) - goto again; - goto loop; - } - } } if (!BN_add_word(rnd, delta)) return 0; @@ -355,16 +317,23 @@ static int probable_prime(BIGNUM *rnd, int bits, prime return 1; } -int bn_probable_prime_dh(BIGNUM *rnd, int bits, - const BIGNUM *add, const BIGNUM *rem, BN_CTX *ctx) +static int probable_prime_dh(BIGNUM *rnd, int bits, int safe, prime_t *mods, + const BIGNUM *add, const BIGNUM *rem, + BN_CTX *ctx) { int i, ret = 0; BIGNUM *t1; + BN_ULONG delta; + BN_ULONG maxdelta = BN_MASK2 - primes[NUMPRIMES - 1]; BN_CTX_start(ctx); if ((t1 = BN_CTX_get(ctx)) == NULL) goto err; + if (maxdelta > BN_MASK2 - BN_get_word(add)) + maxdelta = BN_MASK2 - BN_get_word(add); + + again: if (!BN_rand(rnd, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD)) goto err; @@ -375,98 +344,48 @@ int bn_probable_prime_dh(BIGNUM *rnd, int bits, if (!BN_sub(rnd, rnd, t1)) goto err; if (rem == NULL) { - if (!BN_add_word(rnd, 1)) + if (!BN_add_word(rnd, safe ? 3u : 1u)) goto err; } else { if (!BN_add(rnd, rnd, rem)) goto err; } - /* we now have a random number 'rand' to test. */ + if (BN_num_bits(rnd) < bits + || BN_get_word(rnd) < (safe ? 5u : 3u)) { + if (!BN_add(rnd, rnd, add)) + goto err; + } - loop: + /* we now have a random number 'rnd' to test. */ for (i = 1; i < NUMPRIMES; i++) { - /* check that rnd is a prime */ BN_ULONG mod = BN_mod_word(rnd, (BN_ULONG)primes[i]); if (mod == (BN_ULONG)-1) goto err; - if (mod <= 1) { - if (!BN_add(rnd, rnd, add)) - goto err; - goto loop; - } + mods[i] = (prime_t) mod; } - ret = 1; - - err: - BN_CTX_end(ctx); - bn_check_top(rnd); - return ret; -} - -static int probable_prime_dh_safe(BIGNUM *p, int bits, const BIGNUM *padd, - const BIGNUM *rem, BN_CTX *ctx) -{ - int i, ret = 0; - BIGNUM *t1, *qadd, *q; - - bits--; - BN_CTX_start(ctx); - t1 = BN_CTX_get(ctx); - q = BN_CTX_get(ctx); - qadd = BN_CTX_get(ctx); - if (qadd == NULL) - goto err; - - if (!BN_rshift1(qadd, padd)) - goto err; - - if (!BN_rand(q, bits, BN_RAND_TOP_ONE, BN_RAND_BOTTOM_ODD)) - goto err; - - /* we need ((rnd-rem) % add) == 0 */ - if (!BN_mod(t1, q, qadd, ctx)) - goto err; - if (!BN_sub(q, q, t1)) - goto err; - if (rem == NULL) { - if (!BN_add_word(q, 1)) - goto err; - } else { - if (!BN_rshift1(t1, rem)) - goto err; - if (!BN_add(q, q, t1)) - goto err; - } - - /* we now have a random number 'rand' to test. */ - if (!BN_lshift1(p, q)) - goto err; - if (!BN_add_word(p, 1)) - goto err; - + delta = 0; loop: for (i = 1; i < NUMPRIMES; i++) { - /* check that p and q are prime */ - /* - * check that for p and q gcd(p-1,primes) == 1 (except for 2) - */ - BN_ULONG pmod = BN_mod_word(p, (BN_ULONG)primes[i]); - BN_ULONG qmod = BN_mod_word(q, (BN_ULONG)primes[i]); - if (pmod == (BN_ULONG)-1 || qmod == (BN_ULONG)-1) - goto err; - if (pmod == 0 || qmod == 0) { - if (!BN_add(p, p, padd)) - goto err; - if (!BN_add(q, q, qadd)) - goto err; + /* check that rnd is a prime */ + if (bits <= 31 && delta <= 0x7fffffff + && square(primes[i]) > BN_get_word(rnd) + delta) + break; + /* rnd mod p == 1 implies q = (rnd-1)/2 is divisible by p */ + if (safe ? (mods[i] + delta) % primes[i] <= 1 + : (mods[i] + delta) % primes[i] == 0) { + delta += BN_get_word(add); + if (delta > maxdelta) + goto again; goto loop; } } + if (!BN_add_word(rnd, delta)) + goto err; ret = 1; err: BN_CTX_end(ctx); - bn_check_top(p); + bn_check_top(rnd); return ret; } Modified: vendor-crypto/openssl/dist/crypto/conf/conf_lib.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/conf/conf_lib.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/conf/conf_lib.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 2000-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2000-2020 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 @@ -356,8 +356,10 @@ OPENSSL_INIT_SETTINGS *OPENSSL_INIT_new(void) { OPENSSL_INIT_SETTINGS *ret = malloc(sizeof(*ret)); - if (ret != NULL) - memset(ret, 0, sizeof(*ret)); + if (ret == NULL) + return NULL; + + memset(ret, 0, sizeof(*ret)); ret->flags = DEFAULT_CONF_MFLAGS; return ret; Modified: vendor-crypto/openssl/dist/crypto/err/openssl.txt ============================================================================== --- vendor-crypto/openssl/dist/crypto/err/openssl.txt Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/err/openssl.txt Tue Mar 31 15:25:23 2020 (r359482) @@ -2852,7 +2852,6 @@ SSL_R_UNABLE_TO_LOAD_SSL3_MD5_ROUTINES:242:unable to l SSL_R_UNABLE_TO_LOAD_SSL3_SHA1_ROUTINES:243:unable to load ssl3 sha1 routines SSL_R_UNEXPECTED_CCS_MESSAGE:262:unexpected ccs message SSL_R_UNEXPECTED_END_OF_EARLY_DATA:178:unexpected end of early data -SSL_R_UNEXPECTED_EOF_WHILE_READING:294:unexpected eof while reading SSL_R_UNEXPECTED_MESSAGE:244:unexpected message SSL_R_UNEXPECTED_RECORD:245:unexpected record SSL_R_UNINITIALIZED:276:uninitialized Modified: vendor-crypto/openssl/dist/crypto/ex_data.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/ex_data.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/ex_data.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -235,7 +235,7 @@ int CRYPTO_new_ex_data(int class_index, void *obj, CRY return 0; } for (i = 0; i < mx; i++) { - if (storage[i] && storage[i]->new_func) { + if (storage[i] != NULL && storage[i]->new_func != NULL) { ptr = CRYPTO_get_ex_data(ad, i); storage[i]->new_func(obj, ptr, ad, i, storage[i]->argl, storage[i]->argp); @@ -299,7 +299,7 @@ int CRYPTO_dup_ex_data(int class_index, CRYPTO_EX_DATA for (i = 0; i < mx; i++) { ptr = CRYPTO_get_ex_data(from, i); - if (storage[i] && storage[i]->dup_func) + if (storage[i] != NULL && storage[i]->dup_func != NULL) if (!storage[i]->dup_func(to, from, &ptr, i, storage[i]->argl, storage[i]->argp)) goto err; Modified: vendor-crypto/openssl/dist/crypto/pkcs12/p12_crt.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/pkcs12/p12_crt.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/pkcs12/p12_crt.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1999-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 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 @@ -62,7 +62,8 @@ PKCS12 *PKCS12_create(const char *pass, const char *na if (pkey && cert) { if (!X509_check_private_key(cert, pkey)) return NULL; - X509_digest(cert, EVP_sha1(), keyid, &keyidlen); + if (!X509_digest(cert, EVP_sha1(), keyid, &keyidlen)) + return NULL; } if (cert) { Modified: vendor-crypto/openssl/dist/crypto/ts/ts_rsp_sign.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/ts/ts_rsp_sign.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/ts/ts_rsp_sign.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 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 @@ -771,7 +771,8 @@ static ESS_CERT_ID *ess_CERT_ID_new_init(X509 *cert, i X509_check_purpose(cert, -1, 0); if ((cid = ESS_CERT_ID_new()) == NULL) goto err; - X509_digest(cert, EVP_sha1(), cert_sha1, NULL); + if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) + goto err; if (!ASN1_OCTET_STRING_set(cid->hash, cert_sha1, SHA_DIGEST_LENGTH)) goto err; Modified: vendor-crypto/openssl/dist/crypto/ts/ts_rsp_verify.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/ts/ts_rsp_verify.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/ts/ts_rsp_verify.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 2006-2016 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 2006-2020 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 @@ -289,11 +289,12 @@ static int ts_find_cert(STACK_OF(ESS_CERT_ID) *cert_id if (!cert_ids || !cert) return -1; - X509_digest(cert, EVP_sha1(), cert_sha1, NULL); - /* Recompute SHA1 hash of certificate if necessary (side effect). */ X509_check_purpose(cert, -1, 0); + if (!X509_digest(cert, EVP_sha1(), cert_sha1, NULL)) + return -1; + /* Look for cert in the cert_ids vector. */ for (i = 0; i < sk_ESS_CERT_ID_num(cert_ids); ++i) { ESS_CERT_ID *cid = sk_ESS_CERT_ID_value(cert_ids, i); @@ -326,7 +327,8 @@ static int ts_find_cert_v2(STACK_OF(ESS_CERT_ID_V2) *c else md = EVP_sha256(); - X509_digest(cert, md, cert_digest, &len); + if (!X509_digest(cert, md, cert_digest, &len)) + return -1; if (cid->hash->length != (int)len) return -1; Modified: vendor-crypto/openssl/dist/crypto/x509/x509_cmp.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/x509/x509_cmp.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/x509/x509_cmp.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -134,9 +134,12 @@ unsigned long X509_subject_name_hash_old(X509 *x) int X509_cmp(const X509 *a, const X509 *b) { int rv; + /* ensure hash is valid */ - X509_check_purpose((X509 *)a, -1, 0); - X509_check_purpose((X509 *)b, -1, 0); + if (X509_check_purpose((X509 *)a, -1, 0) != 1) + return -2; + if (X509_check_purpose((X509 *)b, -1, 0) != 1) + return -2; rv = memcmp(a->sha1_hash, b->sha1_hash, SHA_DIGEST_LENGTH); if (rv) Modified: vendor-crypto/openssl/dist/crypto/x509/x509_trs.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/x509/x509_trs.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/x509/x509_trs.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1999-2018 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 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 @@ -240,8 +240,9 @@ static int trust_1oid(X509_TRUST *trust, X509 *x, int static int trust_compat(X509_TRUST *trust, X509 *x, int flags) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, 0); - if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && x->ex_flags & EXFLAG_SS) + if (X509_check_purpose(x, -1, 0) != 1) + return X509_TRUST_UNTRUSTED; + if ((flags & X509_TRUST_NO_SS_COMPAT) == 0 && (x->ex_flags & EXFLAG_SS)) return X509_TRUST_TRUSTED; else return X509_TRUST_UNTRUSTED; Modified: vendor-crypto/openssl/dist/crypto/x509/x509_vfy.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/x509/x509_vfy.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/x509/x509_vfy.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -107,12 +107,8 @@ static int null_callback(int ok, X509_STORE_CTX *e) /* Return 1 is a certificate is self signed */ static int cert_self_signed(X509 *x) { - /* - * FIXME: x509v3_cache_extensions() needs to detect more failures and not - * set EXFLAG_SET when that happens. Especially, if the failures are - * parse errors, rather than memory pressure! - */ - X509_check_purpose(x, -1, 0); + if (X509_check_purpose(x, -1, 0) != 1) + return 0; if (x->ex_flags & EXFLAG_SS) return 1; else Modified: vendor-crypto/openssl/dist/crypto/x509/x_all.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/x509/x_all.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/x509/x_all.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2017 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -362,7 +362,8 @@ int X509_pubkey_digest(const X509 *data, const EVP_MD int X509_digest(const X509 *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { - if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0) { + if (type == EVP_sha1() && (data->ex_flags & EXFLAG_SET) != 0 + && (data->ex_flags & EXFLAG_INVALID) == 0) { /* Asking for SHA1 and we already computed it. */ if (len != NULL) *len = sizeof(data->sha1_hash); @@ -376,7 +377,8 @@ int X509_digest(const X509 *data, const EVP_MD *type, int X509_CRL_digest(const X509_CRL *data, const EVP_MD *type, unsigned char *md, unsigned int *len) { - if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0) { + if (type == EVP_sha1() && (data->flags & EXFLAG_SET) != 0 + && (data->flags & EXFLAG_INVALID) == 0) { /* Asking for SHA1; always computed in CRL d2i. */ if (len != NULL) *len = sizeof(data->sha1_hash); Modified: vendor-crypto/openssl/dist/crypto/x509/x_crl.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/x509/x_crl.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/x509/x_crl.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1995-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1995-2020 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 @@ -17,7 +17,7 @@ static int X509_REVOKED_cmp(const X509_REVOKED *const *a, const X509_REVOKED *const *b); -static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); +static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp); ASN1_SEQUENCE(X509_REVOKED) = { ASN1_EMBED(X509_REVOKED,serialNumber, ASN1_INTEGER), @@ -155,7 +155,7 @@ static int crl_cb(int operation, ASN1_VALUE **pval, co X509_CRL *crl = (X509_CRL *)*pval; STACK_OF(X509_EXTENSION) *exts; X509_EXTENSION *ext; - int idx; + int idx, i; switch (operation) { case ASN1_OP_D2I_PRE: @@ -184,23 +184,35 @@ static int crl_cb(int operation, ASN1_VALUE **pval, co break; case ASN1_OP_D2I_POST: - X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL); + if (!X509_CRL_digest(crl, EVP_sha1(), crl->sha1_hash, NULL)) + crl->flags |= EXFLAG_INVALID; crl->idp = X509_CRL_get_ext_d2i(crl, - NID_issuing_distribution_point, NULL, + NID_issuing_distribution_point, &i, NULL); - if (crl->idp) - setup_idp(crl, crl->idp); + if (crl->idp != NULL) { + if (!setup_idp(crl, crl->idp)) + crl->flags |= EXFLAG_INVALID; + } + else if (i != -1) { + crl->flags |= EXFLAG_INVALID; + } crl->akid = X509_CRL_get_ext_d2i(crl, - NID_authority_key_identifier, NULL, + NID_authority_key_identifier, &i, NULL); + if (crl->akid == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; crl->crl_number = X509_CRL_get_ext_d2i(crl, - NID_crl_number, NULL, NULL); + NID_crl_number, &i, NULL); + if (crl->crl_number == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; crl->base_crl_number = X509_CRL_get_ext_d2i(crl, - NID_delta_crl, NULL, + NID_delta_crl, &i, NULL); + if (crl->base_crl_number == NULL && i != -1) + crl->flags |= EXFLAG_INVALID; /* Delta CRLs must have CRL number */ if (crl->base_crl_number && !crl->crl_number) crl->flags |= EXFLAG_INVALID; @@ -259,9 +271,10 @@ static int crl_cb(int operation, ASN1_VALUE **pval, co /* Convert IDP into a more convenient form */ -static void setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) +static int setup_idp(X509_CRL *crl, ISSUING_DIST_POINT *idp) { int idp_only = 0; + /* Set various flags according to IDP */ crl->idp_flags |= IDP_PRESENT; if (idp->onlyuser > 0) { @@ -292,7 +305,7 @@ static void setup_idp(X509_CRL *crl, ISSUING_DIST_POIN crl->idp_reasons &= CRLDP_ALL_REASONS; } - DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl)); + return DIST_POINT_set_dpname(idp->distpoint, X509_CRL_get_issuer(crl)); } ASN1_SEQUENCE_ref(X509_CRL, crl_cb) = { Modified: vendor-crypto/openssl/dist/crypto/x509v3/v3_purp.c ============================================================================== --- vendor-crypto/openssl/dist/crypto/x509v3/v3_purp.c Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/crypto/x509v3/v3_purp.c Tue Mar 31 15:25:23 2020 (r359482) @@ -1,5 +1,5 @@ /* - * Copyright 1999-2019 The OpenSSL Project Authors. All Rights Reserved. + * Copyright 1999-2020 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 @@ -81,6 +81,8 @@ int X509_check_purpose(X509 *x, int id, int ca) const X509_PURPOSE *pt; x509v3_cache_extensions(x); + if (x->ex_flags & EXFLAG_INVALID) + return -1; /* Return if side-effect only call */ if (id == -1) @@ -300,10 +302,11 @@ int X509_supported_extension(X509_EXTENSION *ex) return 0; } -static void setup_dp(X509 *x, DIST_POINT *dp) +static int setup_dp(X509 *x, DIST_POINT *dp) { X509_NAME *iname = NULL; int i; + if (dp->reasons) { if (dp->reasons->length > 0) dp->dp_reasons = dp->reasons->data[0]; @@ -313,7 +316,7 @@ static void setup_dp(X509 *x, DIST_POINT *dp) } else dp->dp_reasons = CRLDP_ALL_REASONS; if (!dp->distpoint || (dp->distpoint->type != 1)) - return; + return 1; for (i = 0; i < sk_GENERAL_NAME_num(dp->CRLissuer); i++) { GENERAL_NAME *gen = sk_GENERAL_NAME_value(dp->CRLissuer, i); if (gen->type == GEN_DIRNAME) { @@ -324,16 +327,21 @@ static void setup_dp(X509 *x, DIST_POINT *dp) if (!iname) iname = X509_get_issuer_name(x); - DIST_POINT_set_dpname(dp->distpoint, iname); - + return DIST_POINT_set_dpname(dp->distpoint, iname); } -static void setup_crldp(X509 *x) +static int setup_crldp(X509 *x) { int i; - x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, NULL, NULL); - for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) - setup_dp(x, sk_DIST_POINT_value(x->crldp, i)); + + x->crldp = X509_get_ext_d2i(x, NID_crl_distribution_points, &i, NULL); + if (x->crldp == NULL && i != -1) + return 0; + for (i = 0; i < sk_DIST_POINT_num(x->crldp); i++) { + if (!setup_dp(x, sk_DIST_POINT_value(x->crldp, i))) + return 0; + } + return 1; } #define V1_ROOT (EXFLAG_V1|EXFLAG_SS) @@ -366,12 +374,13 @@ static void x509v3_cache_extensions(X509 *x) return; } - X509_digest(x, EVP_sha1(), x->sha1_hash, NULL); + if (!X509_digest(x, EVP_sha1(), x->sha1_hash, NULL)) + x->ex_flags |= EXFLAG_INVALID; /* V1 should mean no extensions ... */ if (!X509_get_version(x)) x->ex_flags |= EXFLAG_V1; /* Handle basic constraints */ - if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, NULL, NULL))) { + if ((bs = X509_get_ext_d2i(x, NID_basic_constraints, &i, NULL))) { if (bs->ca) x->ex_flags |= EXFLAG_CA; if (bs->pathlen) { @@ -385,9 +394,11 @@ static void x509v3_cache_extensions(X509 *x) x->ex_pathlen = -1; BASIC_CONSTRAINTS_free(bs); x->ex_flags |= EXFLAG_BCONS; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } /* Handle proxy certificates */ - if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, NULL, NULL))) { + if ((pci = X509_get_ext_d2i(x, NID_proxyCertInfo, &i, NULL))) { if (x->ex_flags & EXFLAG_CA || X509_get_ext_by_NID(x, NID_subject_alt_name, -1) >= 0 || X509_get_ext_by_NID(x, NID_issuer_alt_name, -1) >= 0) { @@ -399,9 +410,11 @@ static void x509v3_cache_extensions(X509 *x) x->ex_pcpathlen = -1; PROXY_CERT_INFO_EXTENSION_free(pci); x->ex_flags |= EXFLAG_PROXY; + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } /* Handle key usage */ - if ((usage = X509_get_ext_d2i(x, NID_key_usage, NULL, NULL))) { + if ((usage = X509_get_ext_d2i(x, NID_key_usage, &i, NULL))) { if (usage->length > 0) { x->ex_kusage = usage->data[0]; if (usage->length > 1) @@ -410,9 +423,11 @@ static void x509v3_cache_extensions(X509 *x) x->ex_kusage = 0; x->ex_flags |= EXFLAG_KUSAGE; ASN1_BIT_STRING_free(usage); + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } x->ex_xkusage = 0; - if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, NULL, NULL))) { + if ((extusage = X509_get_ext_d2i(x, NID_ext_key_usage, &i, NULL))) { x->ex_flags |= EXFLAG_XKUSAGE; for (i = 0; i < sk_ASN1_OBJECT_num(extusage); i++) { switch (OBJ_obj2nid(sk_ASN1_OBJECT_value(extusage, i))) { @@ -455,18 +470,26 @@ static void x509v3_cache_extensions(X509 *x) } } sk_ASN1_OBJECT_pop_free(extusage, ASN1_OBJECT_free); + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } - if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, NULL, NULL))) { + if ((ns = X509_get_ext_d2i(x, NID_netscape_cert_type, &i, NULL))) { if (ns->length > 0) x->ex_nscert = ns->data[0]; else x->ex_nscert = 0; x->ex_flags |= EXFLAG_NSCERT; ASN1_BIT_STRING_free(ns); + } else if (i != -1) { + x->ex_flags |= EXFLAG_INVALID; } - x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, NULL, NULL); - x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, NULL, NULL); + x->skid = X509_get_ext_d2i(x, NID_subject_key_identifier, &i, NULL); + if (x->skid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + x->akid = X509_get_ext_d2i(x, NID_authority_key_identifier, &i, NULL); + if (x->akid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; /* Does subject name match issuer ? */ if (!X509_NAME_cmp(X509_get_subject_name(x), X509_get_issuer_name(x))) { x->ex_flags |= EXFLAG_SI; @@ -475,16 +498,22 @@ static void x509v3_cache_extensions(X509 *x) !ku_reject(x, KU_KEY_CERT_SIGN)) x->ex_flags |= EXFLAG_SS; } - x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, NULL, NULL); + x->altname = X509_get_ext_d2i(x, NID_subject_alt_name, &i, NULL); + if (x->altname == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; x->nc = X509_get_ext_d2i(x, NID_name_constraints, &i, NULL); - if (!x->nc && (i != -1)) + if (x->nc == NULL && i != -1) x->ex_flags |= EXFLAG_INVALID; - setup_crldp(x); + if (!setup_crldp(x)) + x->ex_flags |= EXFLAG_INVALID; #ifndef OPENSSL_NO_RFC3779 - x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, NULL, NULL); - x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, - NULL, NULL); + x->rfc3779_addr = X509_get_ext_d2i(x, NID_sbgp_ipAddrBlock, &i, NULL); + if (x->rfc3779_addr == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; + x->rfc3779_asid = X509_get_ext_d2i(x, NID_sbgp_autonomousSysNum, &i, NULL); + if (x->rfc3779_asid == NULL && i != -1) + x->ex_flags |= EXFLAG_INVALID; #endif for (i = 0; i < X509_get_ext_count(x); i++) { ex = X509_get_ext(x, i); @@ -777,7 +806,11 @@ int X509_check_issued(X509 *issuer, X509 *subject) return X509_V_ERR_SUBJECT_ISSUER_MISMATCH; x509v3_cache_extensions(issuer); + if (issuer->ex_flags & EXFLAG_INVALID) + return X509_V_ERR_UNSPECIFIED; x509v3_cache_extensions(subject); + if (subject->ex_flags & EXFLAG_INVALID) + return X509_V_ERR_UNSPECIFIED; if (subject->akid) { int ret = X509_check_akid(issuer, subject->akid); @@ -842,7 +875,8 @@ uint32_t X509_get_extension_flags(X509 *x) uint32_t X509_get_key_usage(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return 0; if (x->ex_flags & EXFLAG_KUSAGE) return x->ex_kusage; return UINT32_MAX; @@ -851,7 +885,8 @@ uint32_t X509_get_key_usage(X509 *x) uint32_t X509_get_extended_key_usage(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return 0; if (x->ex_flags & EXFLAG_XKUSAGE) return x->ex_xkusage; return UINT32_MAX; @@ -860,28 +895,32 @@ uint32_t X509_get_extended_key_usage(X509 *x) const ASN1_OCTET_STRING *X509_get0_subject_key_id(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return x->skid; } const ASN1_OCTET_STRING *X509_get0_authority_key_id(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->keyid : NULL); } const GENERAL_NAMES *X509_get0_authority_issuer(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->issuer : NULL); } const ASN1_INTEGER *X509_get0_authority_serial(X509 *x) { /* Call for side-effect of computing hash and caching extensions */ - X509_check_purpose(x, -1, -1); + if (X509_check_purpose(x, -1, -1) != 1) + return NULL; return (x->akid != NULL ? x->akid->serial : NULL); } Modified: vendor-crypto/openssl/dist/doc/man3/BN_generate_prime.pod ============================================================================== --- vendor-crypto/openssl/dist/doc/man3/BN_generate_prime.pod Tue Mar 31 13:48:06 2020 (r359481) +++ vendor-crypto/openssl/dist/doc/man3/BN_generate_prime.pod Tue Mar 31 15:25:23 2020 (r359482) @@ -52,7 +52,9 @@ Deprecated: BN_generate_prime_ex() generates a pseudo-random prime number of at least bit length B. The returned number is probably prime -with a negligible error. +with a negligible error. If B is B the returned prime +number will have exact bit length B with the top most two *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-vendor@freebsd.org Tue Mar 31 15:26:23 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E2DC4260C4B; Tue, 31 Mar 2020 15:26:22 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48sCph5LdBz3wbs; Tue, 31 Mar 2020 15:26:20 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 46A63BFEA; Tue, 31 Mar 2020 15:26:14 +0000 (UTC) (envelope-from jkim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02VFQEGF076401; Tue, 31 Mar 2020 15:26:14 GMT (envelope-from jkim@FreeBSD.org) Received: (from jkim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02VFQEMm076400; Tue, 31 Mar 2020 15:26:14 GMT (envelope-from jkim@FreeBSD.org) Message-Id: <202003311526.02VFQEMm076400@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jkim set sender to jkim@FreeBSD.org using -f From: Jung-uk Kim Date: Tue, 31 Mar 2020 15:26:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359483 - vendor-crypto/openssl/1.1.1f X-SVN-Group: vendor-crypto X-SVN-Commit-Author: jkim X-SVN-Commit-Paths: vendor-crypto/openssl/1.1.1f X-SVN-Commit-Revision: 359483 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 15:26:23 -0000 Author: jkim Date: Tue Mar 31 15:26:13 2020 New Revision: 359483 URL: https://svnweb.freebsd.org/changeset/base/359483 Log: Tag OpenSSL 1.1.1f. Added: vendor-crypto/openssl/1.1.1f/ - copied from r359482, vendor-crypto/openssl/dist/ From owner-svn-src-vendor@freebsd.org Tue Mar 31 17:51:18 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 1D094265560; Tue, 31 Mar 2020 17:51:18 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48sH1w6Jlqz3PDM; Tue, 31 Mar 2020 17:51:16 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 1E6EBDE51; Tue, 31 Mar 2020 17:50:34 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02VHoXTN065621; Tue, 31 Mar 2020 17:50:33 GMT (envelope-from harti@FreeBSD.org) Received: (from harti@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02VHoWCk065614; Tue, 31 Mar 2020 17:50:32 GMT (envelope-from harti@FreeBSD.org) Message-Id: <202003311750.02VHoWCk065614@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: harti set sender to harti@FreeBSD.org using -f From: Hartmut Brandt Date: Tue, 31 Mar 2020 17:50:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359490 - in vendor/bsnmp/dist: . config gensnmpdef gensnmptree lib snmp_mibII snmp_ntp snmp_target snmp_usm snmp_vacm snmpd tests X-SVN-Group: vendor X-SVN-Commit-Author: harti X-SVN-Commit-Paths: in vendor/bsnmp/dist: . config gensnmpdef gensnmptree lib snmp_mibII snmp_ntp snmp_target snmp_usm snmp_vacm snmpd tests X-SVN-Commit-Revision: 359490 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 17:51:18 -0000 Author: harti Date: Tue Mar 31 17:50:32 2020 New Revision: 359490 URL: https://svnweb.freebsd.org/changeset/base/359490 Log: Import version 1.14 of bsnmp. This mainly consists of bug fixes in the ASN.1 functions and comes with a test suite for these functions. Added: vendor/bsnmp/dist/snmpd/trans_inet.c (contents, props changed) vendor/bsnmp/dist/snmpd/trans_inet.h (contents, props changed) vendor/bsnmp/dist/tests/ vendor/bsnmp/dist/tests/asn1.cc (contents, props changed) vendor/bsnmp/dist/tests/catch.hpp (contents, props changed) vendor/bsnmp/dist/tests/constbuf.h (contents, props changed) vendor/bsnmp/dist/tests/main.cc (contents, props changed) vendor/bsnmp/dist/tests/snmp_parse_server.cc (contents, props changed) Deleted: vendor/bsnmp/dist/Makefile.in vendor/bsnmp/dist/README.1st vendor/bsnmp/dist/config/ vendor/bsnmp/dist/configure.ac vendor/bsnmp/dist/gensnmpdef/Makefile.in vendor/bsnmp/dist/gensnmptree/Makefile.in vendor/bsnmp/dist/lib/Makefile.in vendor/bsnmp/dist/lib/snmptc.h.in vendor/bsnmp/dist/libbsnmp.pc.in vendor/bsnmp/dist/snmp_mibII/Makefile.in vendor/bsnmp/dist/snmp_ntp/Makefile.in vendor/bsnmp/dist/snmp_target/Makefile.in vendor/bsnmp/dist/snmp_usm/Makefile.in vendor/bsnmp/dist/snmp_vacm/Makefile.in vendor/bsnmp/dist/snmpd/Makefile.in Modified: vendor/bsnmp/dist/gensnmptree/gensnmptree.1 vendor/bsnmp/dist/gensnmptree/gensnmptree.c vendor/bsnmp/dist/lib/asn1.c vendor/bsnmp/dist/lib/bsnmpclient.3 vendor/bsnmp/dist/lib/snmp.h vendor/bsnmp/dist/lib/snmpclient.c vendor/bsnmp/dist/lib/snmpclient.h vendor/bsnmp/dist/lib/snmpcrypto.c vendor/bsnmp/dist/lib/tc.def vendor/bsnmp/dist/snmp_mibII/mibII.c vendor/bsnmp/dist/snmp_mibII/mibII.h vendor/bsnmp/dist/snmp_mibII/mibII_interfaces.c vendor/bsnmp/dist/snmp_mibII/snmp_mibII.h vendor/bsnmp/dist/snmp_ntp/snmp_ntp.c vendor/bsnmp/dist/snmp_target/target_snmp.c vendor/bsnmp/dist/snmp_usm/usm_snmp.c vendor/bsnmp/dist/snmp_vacm/vacm_snmp.c vendor/bsnmp/dist/snmpd/BEGEMOT-SNMPD.txt vendor/bsnmp/dist/snmpd/main.c vendor/bsnmp/dist/snmpd/snmpd.config vendor/bsnmp/dist/snmpd/snmpd.h vendor/bsnmp/dist/snmpd/snmpmod.h vendor/bsnmp/dist/snmpd/trans_lsock.c vendor/bsnmp/dist/snmpd/trans_udp.c vendor/bsnmp/dist/snmpd/trap.c vendor/bsnmp/dist/snmpd/tree.def Modified: vendor/bsnmp/dist/gensnmptree/gensnmptree.1 ============================================================================== --- vendor/bsnmp/dist/gensnmptree/gensnmptree.1 Tue Mar 31 16:47:15 2020 (r359489) +++ vendor/bsnmp/dist/gensnmptree/gensnmptree.1 Tue Mar 31 17:50:32 2020 (r359490) @@ -2,7 +2,7 @@ .\" Copyright (c) 2001-2005 .\" Fraunhofer Institute for Open Communication Systems (FhG Fokus). .\" All rights reserved. -.\" Copyright (c) 2006 +.\" Copyright (c) 2006,2018 .\" Hartmut Brandt .\" All rights reserved. .\" @@ -31,7 +31,7 @@ .\" .\" $Begemot: gensnmptree.1 383 2006-05-30 07:40:49Z brandt_h $ .\" -.Dd May 26, 2006 +.Dd April 2, 2019 .Dt GENSNMPTREE 1 .Os .Sh NAME @@ -39,7 +39,7 @@ .Nd "generate C and header files from a MIB description file" .Sh SYNOPSIS .Nm -.Op Fl dEehlt +.Op Fl dEeFfhlt .Op Fl I Ar directory .Op Fl i Ar infile .Op Fl p Ar prefix @@ -99,6 +99,12 @@ is the length of the OID. .It Va OID_ Ns Ar name is the last component of the OID. .El +.It Fl F +emit definitions for C-functions includeable in a C-file that do some basic +stuff on enums like value checking and conversion between value and strings. +.It Fl f +emit definitions for inline C-functions that do some basic +stuff on enums like value checking and conversion between value and strings. .It Fl h Print a short help page. .It Fl I Ar directory Modified: vendor/bsnmp/dist/gensnmptree/gensnmptree.c ============================================================================== --- vendor/bsnmp/dist/gensnmptree/gensnmptree.c Tue Mar 31 16:47:15 2020 (r359489) +++ vendor/bsnmp/dist/gensnmptree/gensnmptree.c Tue Mar 31 17:50:32 2020 (r359490) @@ -123,9 +123,40 @@ options:\n\ -i ifile read from the named file instead of stdin\n\ -l generate local include directives\n\ -p prefix prepend prefix to file and variable names\n\ - -t generated a .def file\n\ + -t generate a .def file\n\ "; +/** + * Program operation. + */ +enum op { + /** generate the tree */ + OP_GEN, + + /** extract OIDs */ + OP_EXTRACT, + + /** print the parsed tree */ + OP_TREE, + + /** extract enums */ + OP_ENUMS, +}; + +/** + * Which functions to create. + */ +enum gen_funcs { + /** none */ + GEN_FUNCS_NONE, + + /** functions for header files */ + GEN_FUNCS_H, + + /** functions for C files */ + GEN_FUNCS_C, +}; + /* * A node in the OID tree */ @@ -161,15 +192,18 @@ struct node { uint32_t index; /* index for table entry */ char *func; /* function for tables */ struct node_list subs; + char *subtypes[SNMP_INDEXES_MAX]; } entry; struct leaf { enum snmp_syntax syntax; /* syntax for this leaf */ char *func; /* function name */ + char *subtype; /* subtype */ } leaf; struct column { enum snmp_syntax syntax; /* syntax for this column */ + char *subtype; /* subtype */ } column; } u; }; @@ -213,7 +247,7 @@ xalloc(size_t size) { void *ptr; - if ((ptr = malloc(size)) == NULL) + if ((ptr = calloc(1, size)) == NULL) err(1, "allocing %zu bytes", size); return (ptr); @@ -709,12 +743,14 @@ make_type(const char *s) * token. */ static u_int -parse_type(enum tok *tok, struct type *t, const char *vname) +parse_type(enum tok *tok, struct type *t, const char *vname, char **subtype) { u_int syntax; struct enums *e; syntax = val; + if (subtype != NULL) + *subtype = NULL; if (*tok == TOK_ENUM || *tok == TOK_BITS) { if (t == NULL && vname != NULL) { @@ -758,6 +794,8 @@ parse_type(enum tok *tok, struct type *t, const char * if ((*tok = gettoken()) == '|') { if (gettoken() != TOK_STR) report("subtype expected after '|'"); + if (subtype != NULL) + *subtype = savetok(); *tok = gettoken(); } } @@ -793,18 +831,21 @@ parse(enum tok tok) if ((tok = gettoken()) == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { /* LEAF or COLUM */ - u_int syntax = parse_type(&tok, NULL, node->name); + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, &subtype); if (tok == TOK_STR) { /* LEAF */ node->type = NODE_LEAF; node->u.leaf.func = savetok(); node->u.leaf.syntax = syntax; + node->u.leaf.subtype = subtype; tok = gettoken(); } else { /* COLUMN */ node->type = NODE_COLUMN; node->u.column.syntax = syntax; + node->u.column.subtype = subtype; } while (tok != ')') { @@ -824,9 +865,12 @@ parse(enum tok tok) tok = gettoken(); while (tok == TOK_TYPE || tok == TOK_DEFTYPE || tok == TOK_ENUM || tok == TOK_BITS) { - u_int syntax = parse_type(&tok, NULL, node->name); - if (index_count++ == SNMP_INDEXES_MAX) + char *subtype; + u_int syntax = parse_type(&tok, NULL, node->name, + &subtype); + if (index_count == SNMP_INDEXES_MAX) report("too many table indexes"); + node->u.entry.subtypes[index_count++] = subtype; node->u.entry.index |= syntax << (SNMP_INDEX_SHIFT * index_count); } @@ -881,7 +925,8 @@ parse_top(enum tok tok) tok = gettoken(); t->is_enum = (tok == TOK_ENUM); t->is_bits = (tok == TOK_BITS); - t->syntax = parse_type(&tok, t, NULL); + + t->syntax = parse_type(&tok, t, NULL, NULL); pushback(tok); return (NULL); @@ -902,7 +947,7 @@ parse_top(enum tok tok) * Generate the C-code table part for one node. */ static void -gen_node(FILE *fp, struct node *np, struct asn_oid *oid, u_int idx, +gen_node(FILE *fp, const struct node *np, struct asn_oid *oid, u_int idx, const char *func) { u_int n; @@ -1007,7 +1052,7 @@ gen_node(FILE *fp, struct node *np, struct asn_oid *oi * Generate the header file with the function declarations. */ static void -gen_header(FILE *fp, struct node *np, u_int oidlen, const char *func) +gen_header(FILE *fp, const struct node *np, u_int oidlen, const char *func) { char f[MAXSTR + 4]; struct node *sub; @@ -1057,7 +1102,7 @@ gen_header(FILE *fp, struct node *np, u_int oidlen, co * Generate the OID table. */ static void -gen_table(FILE *fp, struct node *node) +gen_table(FILE *fp, const struct node *node) { struct asn_oid oid; @@ -1116,6 +1161,8 @@ gen_tree(const struct node *np, int level) case NODE_LEAF: print_syntax(np->u.leaf.syntax); + if (np->u.leaf.subtype != NULL) + printf(" | %s", np->u.leaf.subtype); printf(" %s%s%s)\n", np->u.leaf.func, (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); @@ -1135,8 +1182,11 @@ gen_tree(const struct node *np, int level) case NODE_ENTRY: printf(" :"); - for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) + for (i = 0; i < SNMP_INDEX_COUNT(np->u.entry.index); i++) { print_syntax(SNMP_INDEX(np->u.entry.index, i)); + if (np->u.entry.subtypes[i] != NULL) + printf(" | %s", np->u.entry.subtypes[i]); + } printf(" %s\n", np->u.entry.func); TAILQ_FOREACH(sp, &np->u.entry.subs, link) gen_tree(sp, level + 1); @@ -1145,6 +1195,8 @@ gen_tree(const struct node *np, int level) case NODE_COLUMN: print_syntax(np->u.column.syntax); + if (np->u.column.subtype != NULL) + printf(" | %s", np->u.column.subtype); printf("%s%s)\n", (np->flags & FL_GET) ? " GET" : "", (np->flags & FL_SET) ? " SET" : ""); break; @@ -1380,45 +1432,6 @@ unminus(FILE *fp, const char *s) } /** - * Generate a definition for the enum packed into a guard against multiple - * definitions. - * - * \param fp file to write definition to - * \param t type - */ -static void -gen_enum(FILE *fp, const struct type *t) -{ - const struct enums *e; - long min = LONG_MAX; - - fprintf(fp, "\n"); - fprintf(fp, "#ifndef %s_defined__\n", t->name); - fprintf(fp, "#define %s_defined__\n", t->name); - fprintf(fp, "/*\n"); - fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); - fprintf(fp, " */\n"); - fprintf(fp, "enum %s {\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t%s_", t->name); - unminus(fp, e->name); - fprintf(fp, " = %ld,\n", e->value); - if (e->value < min) - min = e->value; - } - fprintf(fp, "};\n"); - fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); - fprintf(fp, "#define STRING_%s \\\n", t->name); - TAILQ_FOREACH(e, &t->enums, link) { - fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); - unminus(fp, e->name); - fprintf(fp, "\",\\\n"); - } - fprintf(fp, "\n"); - fprintf(fp, "#endif /* %s_defined__ */\n", t->name); -} - -/** * Generate helper functions for an enum. * * We always generate a switch statement for the isok function. The compiler @@ -1483,6 +1496,54 @@ gen_enum_funcs(FILE *fp, const struct type *t, int cco } /** + * Generate a definition for the enum packed into a guard against multiple + * definitions. + * + * \param fp file to write definition to + * \param t type + * \param dof generate functions too + */ +static void +gen_enum(FILE *fp, const struct type *t, int dof) +{ + const struct enums *e; + long min = LONG_MAX; + + fprintf(fp, "\n"); + fprintf(fp, "#ifndef %s_defined__\n", t->name); + fprintf(fp, "#define %s_defined__\n", t->name); + fprintf(fp, "/*\n"); + fprintf(fp, " * From %s:%u\n", t->from_fname, t->from_lno); + fprintf(fp, " */\n"); + fprintf(fp, "enum %s {\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t%s_", t->name); + unminus(fp, e->name); + fprintf(fp, " = %ld,\n", e->value); + if (e->value < min) + min = e->value; + } + fprintf(fp, "};\n"); + fprintf(fp, "#define STROFF_%s %ld\n", t->name, min); + fprintf(fp, "#define STRING_%s \\\n", t->name); + TAILQ_FOREACH(e, &t->enums, link) { + fprintf(fp, "\t[%ld] = \"%s_", e->value - min, t->name); + unminus(fp, e->name); + fprintf(fp, "\",\\\n"); + } + fprintf(fp, "\n"); + if (dof) { + fprintf(fp, "#ifdef SNMPENUM_FUNCS\n"); + fprintf(fp, "\n"); + gen_enum_funcs(fp, t, 0); + fprintf(fp, "\n"); + fprintf(fp, "#endif\n"); + fprintf(fp, "\n"); + } + fprintf(fp, "#endif /* %s_defined__ */\n", t->name); +} + +/** * Generate helper functions for an enum. This generates code for a c file. * * \param fp file to write to @@ -1519,13 +1580,13 @@ gen_all_enum_funcs(FILE *fp, int ccode) } static void -gen_enums(FILE *fp) +gen_enums(FILE *fp, int dof) { const struct type *t; LIST_FOREACH(t, &types, link) if (t->is_enum || t->is_bits) - gen_enum(fp, t); + gen_enum(fp, t, dof); } /** @@ -1545,9 +1606,7 @@ extract_enum(FILE *fp, const char *name, int gen_funcs LIST_FOREACH(t, &types, link) if ((t->is_enum || t->is_bits) && strcmp(t->name, name) == 0) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); + gen_enum(fp, t, gen_funcs); return (0); } return (-1); @@ -1566,11 +1625,8 @@ extract_all_enums(FILE *fp, int gen_funcs) const struct type *t; LIST_FOREACH(t, &types, link) - if (t->is_enum || t->is_bits) { - gen_enum(fp, t); - if (gen_funcs) - gen_enum_funcs(fp, t, 0); - } + if (t->is_enum || t->is_bits) + gen_enum(fp, t, gen_funcs); } /** @@ -1578,13 +1634,12 @@ extract_all_enums(FILE *fp, int gen_funcs) * * \param argc number of arguments * \param argv arguments (enum names) - * \param gen_funcs_h generate functions into the header file - * \param gen_funcs_c generate a .c file with functions + * \param gen_funcs which functions to generate */ static void -make_enums(int argc, char *argv[], int gen_funcs_h, int gen_funcs_c) +make_enums(int argc, char *argv[], enum gen_funcs gen_funcs) { - if (gen_funcs_c) { + if (gen_funcs == GEN_FUNCS_C) { if (argc == 0) gen_all_enum_funcs(stdout, 1); else { @@ -1594,30 +1649,58 @@ make_enums(int argc, char *argv[], int gen_funcs_h, in } } else { if (argc == 0) - extract_all_enums(stdout, gen_funcs_h); + extract_all_enums(stdout, gen_funcs == GEN_FUNCS_H); else { for (int i = 0; i < argc; i++) - if (extract_enum(stdout, argv[i], gen_funcs_h)) + if (extract_enum(stdout, argv[i], + gen_funcs == GEN_FUNCS_H)) errx(1, "enum not found: %s", argv[i]); } } } +/** + * Produce the operation tables for the daemon or a module. + * + * \param root tree root + * \param gen_funcs generate enum funcs + */ +static void +make_table(const struct node *root, int gen_funcs) +{ + FILE *fp; + + char fname[MAXPATHLEN + 1]; + sprintf(fname, "%stree.h", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_header(fp, root, PREFIX_LEN, NULL); + + fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); + gen_enums(fp, gen_funcs); + fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); + + fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); + fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); + + fclose(fp); + + sprintf(fname, "%stree.c", file_prefix); + if ((fp = fopen(fname, "w")) == NULL) + err(1, "%s: ", fname); + gen_table(fp, root); + fclose(fp); +} + int main(int argc, char *argv[]) { - int do_extract = 0; - int do_tree = 0; - int do_enums = 0; - int gen_funcs_h = 0; - int gen_funcs_c = 0; - int opt; - struct node *root; - char fname[MAXPATHLEN + 1]; - int tok; - FILE *fp; + enum op op = OP_GEN; + enum gen_funcs gen_funcs = GEN_FUNCS_NONE; + char *infile = NULL; + int opt; while ((opt = getopt(argc, argv, "dEeFfhI:i:lp:t")) != EOF) switch (opt) { @@ -1626,19 +1709,29 @@ main(int argc, char *argv[]) break; case 'E': - do_enums = 1; + if (op != OP_GEN && op != OP_ENUMS) + errx(1, "-E conflicts with earlier options"); + op = OP_ENUMS; break; case 'e': - do_extract = 1; + if (op != OP_GEN && op != OP_EXTRACT) + errx(1, "-e conflicts with earlier options"); + op = OP_EXTRACT; break; case 'F': - gen_funcs_c = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_C) + errx(1, "-F conflicts with -f"); + gen_funcs = GEN_FUNCS_C; break; case 'f': - gen_funcs_h = 1; + if (gen_funcs != GEN_FUNCS_NONE && + gen_funcs != GEN_FUNCS_H) + errx(1, "-f conflicts with -F"); + gen_funcs = GEN_FUNCS_H; break; case 'h': @@ -1665,73 +1758,61 @@ main(int argc, char *argv[]) break; case 't': - do_tree = 1; + if (op != OP_GEN && op != OP_TREE) + errx(1, "-t conflicts with earlier options"); + op = OP_TREE; break; } - if (do_extract + do_tree + do_enums > 1) - errx(1, "conflicting options -e/-t/-E"); - if (!do_extract && !do_enums && argc != optind) - errx(1, "no arguments allowed"); - if (do_extract && argc == optind) - errx(1, "no objects specified"); + argc -= optind; + argv += optind; - if ((gen_funcs_h || gen_funcs_c) && !do_enums) - errx(1, "-f and -F require -E"); - if (gen_funcs_h && gen_funcs_c) - errx(1, "-f and -F are mutually exclusive"); - + /* open input */ if (infile == NULL) { input_new(stdin, NULL, ""); } else { + FILE *fp; if ((fp = fopen(infile, "r")) == NULL) err(1, "%s", infile); input_new(fp, NULL, infile); } - root = parse_top(gettoken()); + /* parse and check input */ + struct node *root = parse_top(gettoken()); + + int tok; while ((tok = gettoken()) != TOK_EOF) merge(&root, parse_top(tok)); if (root) check_tree(root); - if (do_extract) { - while (optind < argc) { - if (gen_extract(stdout, root, argv[optind])) - errx(1, "object not found: %s", argv[optind]); - optind++; - } + /* do what the user has requested */ + switch (op) { + + case OP_EXTRACT: + if (argc == 0) + errx(1, "-e requires arguments"); + + for (int i = 0; i < argc; i++) + if (gen_extract(stdout, root, argv[i])) + errx(1, "object not found: %s", argv[i]); return (0); - } - if (do_enums) { - make_enums(argc - optind, argv + optind, - gen_funcs_h, gen_funcs_c); + + case OP_ENUMS: + make_enums(argc, argv, gen_funcs); return (0); - } - if (do_tree) { + + case OP_TREE: + if (argc != 0) + errx(1, "-t allows no arguments"); gen_tree(root, 0); return (0); - } - sprintf(fname, "%stree.h", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_header(fp, root, PREFIX_LEN, NULL); - fprintf(fp, "\n#ifdef SNMPTREE_TYPES\n"); - gen_enums(fp); - fprintf(fp, "\n#endif /* SNMPTREE_TYPES */\n\n"); - - fprintf(fp, "#define %sCTREE_SIZE %u\n", file_prefix, tree_size); - fprintf(fp, "extern const struct snmp_node %sctree[];\n", file_prefix); - - fclose(fp); - - sprintf(fname, "%stree.c", file_prefix); - if ((fp = fopen(fname, "w")) == NULL) - err(1, "%s: ", fname); - gen_table(fp, root); - fclose(fp); - - return (0); + case OP_GEN: + if (argc != 0) + errx(1, "tree generation allows no arguments"); + make_table(root, gen_funcs == GEN_FUNCS_H); + return (0); + } } Modified: vendor/bsnmp/dist/lib/asn1.c ============================================================================== --- vendor/bsnmp/dist/lib/asn1.c Tue Mar 31 16:47:15 2020 (r359489) +++ vendor/bsnmp/dist/lib/asn1.c Tue Mar 31 17:50:32 2020 (r359490) @@ -65,8 +65,8 @@ asn_get_header(struct asn_buf *b, u_char *type, asn_le return (ASN_ERR_EOBUF); } *type = *b->asn_cptr; - if ((*type & ASN_TYPE_MASK) > 0x30) { - asn_error(b, "types > 0x30 not supported (%u)", + if ((*type & ASN_TYPE_MASK) > 0x1e) { + asn_error(b, "tags > 0x1e not supported (%#x)", *type & ASN_TYPE_MASK); return (ASN_ERR_FAILED); } @@ -100,6 +100,19 @@ asn_get_header(struct asn_buf *b, u_char *type, asn_le *len = *b->asn_cptr++; b->asn_len--; } + +#ifdef BOGUS_CVE_2019_5610_FIX + /* + * This is the fix from CVE-2019-5610. + * + * This is the wrong place. Each of the asn functions should check + * that it has enough info for its own work. + */ + if (*len > b->asn_len) { + asn_error(b, "lenen %u exceeding asn_len %u", *len, b->asn_len); + return (ASN_ERR_EOBUF); + } +#endif return (ASN_ERR_OK); } @@ -142,7 +155,7 @@ asn_put_len(u_char *ptr, asn_len_t len) /* * Write a header (tag and length fields). - * Tags are restricted to one byte tags (value <= 0x30) and the + * Tags are restricted to one byte tags (value <= 0x1e) and the * lenght field to 16-bit. All errors stop the encoding. */ enum asn_err @@ -151,8 +164,8 @@ asn_put_header(struct asn_buf *b, u_char type, asn_len u_int lenlen; /* tag field */ - if ((type & ASN_TYPE_MASK) > 0x30) { - asn_error(NULL, "types > 0x30 not supported (%u)", + if ((type & ASN_TYPE_MASK) > 0x1e) { + asn_error(NULL, "types > 0x1e not supported (%#x)", type & ASN_TYPE_MASK); return (ASN_ERR_FAILED); } @@ -246,9 +259,10 @@ asn_get_real_integer(struct asn_buf *b, asn_len_t len, return (ASN_ERR_BADLEN); } err = ASN_ERR_OK; - if (len > 8) + if (len > 8) { + asn_error(b, "integer too long"); err = ASN_ERR_RANGE; - else if (len > 1 && + } else if (len > 1 && ((*b->asn_cptr == 0x00 && (b->asn_cptr[1] & 0x80) == 0) || (*b->asn_cptr == 0xff && (b->asn_cptr[1] & 0x80) == 0x80))) { asn_error(b, "non-minimal integer"); @@ -326,27 +340,35 @@ asn_put_real_integer(struct asn_buf *b, u_char type, i static enum asn_err asn_get_real_unsigned(struct asn_buf *b, asn_len_t len, uint64_t *vp) { - enum asn_err err; - + *vp = 0; if (b->asn_len < len) { asn_error(b, "truncated integer"); return (ASN_ERR_EOBUF); } if (len == 0) { + /* X.690: 8.3.1 */ asn_error(b, "zero-length integer"); - *vp = 0; return (ASN_ERR_BADLEN); } - err = ASN_ERR_OK; - *vp = 0; - if ((*b->asn_cptr & 0x80) || (len == 9 && *b->asn_cptr != 0)) { + if (len > 1 && *b->asn_cptr == 0x00 && (b->asn_cptr[1] & 0x80) == 0) { + /* X.690: 8.3.2 */ + asn_error(b, "non-minimal unsigned"); + b->asn_cptr += len; + b->asn_len -= len; + return (ASN_ERR_BADLEN); + + } + + enum asn_err err = ASN_ERR_OK; + + if ((*b->asn_cptr & 0x80) || len > 9 || + (len == 9 && *b->asn_cptr != 0)) { /* negative integer or too larger */ *vp = 0xffffffffffffffffULL; - err = ASN_ERR_RANGE; - } else if (len > 1 && - *b->asn_cptr == 0x00 && (b->asn_cptr[1] & 0x80) == 0) { - asn_error(b, "non-minimal unsigned"); - err = ASN_ERR_BADLEN; + asn_error(b, "unsigned too large or negative"); + b->asn_cptr += len; + b->asn_len -= len; + return (ASN_ERR_RANGE); } while (len--) { @@ -400,11 +422,14 @@ asn_get_integer_raw(struct asn_buf *b, asn_len_t len, enum asn_err ret; if ((ret = asn_get_real_integer(b, len, &val)) == ASN_ERR_OK) { - if (len > 4) + if (len > 4) { + asn_error(b, "integer too long"); ret = ASN_ERR_BADLEN; - else if (val > INT32_MAX || val < INT32_MIN) + } else if (val > INT32_MAX || val < INT32_MIN) { /* may not happen */ + asn_error(b, "integer out of range"); ret = ASN_ERR_RANGE; + } *vp = (int32_t)val; } return (ret); @@ -584,7 +609,7 @@ asn_get_objid_raw(struct asn_buf *b, asn_len_t len, st return (ASN_ERR_EOBUF); } if (subid > (ASN_MAXID >> 7)) { - asn_error(b, "OBID subid too larger"); + asn_error(b, "OID subid too larger"); err = ASN_ERR_RANGE; } subid = (subid << 7) | (*b->asn_cptr & 0x7f); @@ -640,7 +665,7 @@ asn_put_objid(struct asn_buf *b, const struct asn_oid oidlen = 2; } else if (oid->len == 1) { /* illegal */ - asn_error(b, "short oid"); + asn_error(NULL, "short oid"); if (oid->subs[0] > 2) asn_error(NULL, "oid[0] too large (%u)", oid->subs[0]); err = ASN_ERR_RANGE; @@ -652,7 +677,8 @@ asn_put_objid(struct asn_buf *b, const struct asn_oid err = ASN_ERR_RANGE; } if (oid->subs[0] > 2 || - (oid->subs[0] < 2 && oid->subs[1] >= 40)) { + (oid->subs[0] < 2 && oid->subs[1] >= 40) || + (oid->subs[0] == 2 && oid->subs[1] > ASN_MAXID - 2 * 40)) { asn_error(NULL, "oid out of range (%u,%u)", oid->subs[0], oid->subs[1]); err = ASN_ERR_RANGE; @@ -809,10 +835,7 @@ asn_get_uint32_raw(struct asn_buf *b, asn_len_t len, u enum asn_err err; if ((err = asn_get_real_unsigned(b, len, &v)) == ASN_ERR_OK) { - if (len > 5) { - asn_error(b, "uint32 too long %u", len); - err = ASN_ERR_BADLEN; - } else if (v > UINT32_MAX) { + if (v > UINT32_MAX) { asn_error(b, "uint32 too large %llu", v); err = ASN_ERR_RANGE; } Modified: vendor/bsnmp/dist/lib/bsnmpclient.3 ============================================================================== --- vendor/bsnmp/dist/lib/bsnmpclient.3 Tue Mar 31 16:47:15 2020 (r359489) +++ vendor/bsnmp/dist/lib/bsnmpclient.3 Tue Mar 31 17:50:32 2020 (r359490) @@ -31,7 +31,7 @@ .\" .\" $Begemot: bsnmp/lib/bsnmpclient.3,v 1.12 2005/10/04 08:46:50 brandt_h Exp $ .\" -.Dd December 31, 2016 +.Dd March 31, 2020 .Dt BSNMPCLIENT 3 .Os .Sh NAME @@ -177,7 +177,9 @@ If it is a local stream socket is used. For .Dv SNMP_TRANS_UDP -a UDP socket is created. +a UDPv4 socket and for +.Dv SNMP_TRANS_UDP6 +a UDPv6 socket is created. It uses the .Va chost field as the path to the server's socket for local sockets. @@ -675,7 +677,12 @@ The syntax of a server specification is .Pp where .Va trans -is the transport name (one of udp, stream or dgram), +is the transport name (one of +.Qq udp , +.Qq udp6 , +.Qq stream +or +.Qq dgram ) , .Va community is the string to be used for both the read and the write community, .Va server @@ -685,13 +692,51 @@ of a local socket, and is the port in case of UDP transport. The function returns 0 in the case of success and return -1 and sets the error string in case of an error. +.Pp +The function +.Fn snmp_parse_serverr +fills the transport, the port number and the community strings with +reasonable default values when they are not specified. +The default transport +is +.Dv SNMP_TRANS_UDP . +If the host name contains a slash the default is modified to +.Dv SNMP_TRANS_LOC_DGRAM . +If the host name looks like a numeric IPv6 address the default is +.Dv SNMP_TRANS_UDP6 . +For numeric IPv6 addresses the transport name udp is automatically +translated as +.Dv SNMP_TRANS_UDP6 . +The default port number (for +.Dv udp +or +.Dv udp6 ) +is +.Qq snmp . +The default read community is +.Qq public +and the default write community +.Qq private . +.Pp +.Fn snmp_parse_server +recognizes path names, host names and numerical IPv4 and IPv6 addresses. +A string consisting of digits and periods is assumed to be an IPv4 address +and must be parseable by +.Fn inet_aton 3 . +An IPv6 address is any string enclosed in square brackets. +It must be parseable with +.Fn gethostinfo 3 . +.Pp +The port number for +.Fn snmp_parse_server +can be specified numerically or symbolically. +It is ignored for local sockets. .Sh DIAGNOSTICS -If an error occurs in any of the function an error indication as described +If an error occurs in any of the functions an error indication as described above is returned. -Additionally the function sets a printable error string -in the +Additionally the function sets a printable error string in the .Va error -filed of +field of .Va snmp_client . .Sh SEE ALSO .Xr gensnmptree 1 , Modified: vendor/bsnmp/dist/lib/snmp.h ============================================================================== --- vendor/bsnmp/dist/lib/snmp.h Tue Mar 31 16:47:15 2020 (r359489) +++ vendor/bsnmp/dist/lib/snmp.h Tue Mar 31 17:50:32 2020 (r359490) @@ -42,6 +42,9 @@ #include +#define BSNMP_MAJOR 1 +#define BSNMP_MINOR 13 + #define SNMP_COMMUNITY_MAXLEN 128 #define SNMP_MAX_BINDINGS 100 #define SNMP_CONTEXT_NAME_SIZ (32 + 1) Modified: vendor/bsnmp/dist/lib/snmpclient.c ============================================================================== --- vendor/bsnmp/dist/lib/snmpclient.c Tue Mar 31 16:47:15 2020 (r359489) +++ vendor/bsnmp/dist/lib/snmpclient.c Tue Mar 31 17:50:32 2020 (r359490) @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2005 + * Copyright (c) 2004-2005,2018-2019 * Hartmut Brandt. * All rights reserved. * Copyright (c) 2001-2003 @@ -34,11 +34,13 @@ * * Support functions for SNMP clients. */ -#include +#include #include #include #include #include +#include +#include #include #include #include @@ -58,12 +60,16 @@ #include #endif +#include + #include "support.h" #include "asn1.h" #include "snmp.h" #include "snmpclient.h" #include "snmppriv.h" +#define DEBUG_PARSE 0 + /* global context */ struct snmp_client snmp_client; @@ -474,7 +480,7 @@ table_check_response(struct tabwork *work, const struc if (snmp_client.version == SNMP_V1 && resp->error_status == SNMP_ERR_NOSUCHNAME && resp->error_index == - (work->descr->last_change.len == 0) ? 1 : 2) + ((work->descr->last_change.len == 0) ? 1 : 2)) /* EOT */ return (0); /* Error */ @@ -924,7 +930,8 @@ open_client_udp(const char *host, const char *port) /* open connection */ memset(&hints, 0, sizeof(hints)); hints.ai_flags = AI_CANONNAME; - hints.ai_family = AF_INET; + hints.ai_family = snmp_client.trans == SNMP_TRANS_UDP ? AF_INET : + AF_INET6; hints.ai_socktype = SOCK_DGRAM; hints.ai_protocol = 0; error = getaddrinfo(snmp_client.chost, snmp_client.cport, &hints, &res0); @@ -1068,6 +1075,7 @@ snmp_open(const char *host, const char *port, const ch switch (snmp_client.trans) { case SNMP_TRANS_UDP: + case SNMP_TRANS_UDP6: if (open_client_udp(host, port) != 0) return (-1); break; @@ -1866,99 +1874,425 @@ snmp_client_set_port(struct snmp_client *cl, const cha return (0); } -/* - * parse a server specification +static const char *const trans_list[] = { + [SNMP_TRANS_UDP] = "udp::", + [SNMP_TRANS_LOC_DGRAM] = "dgram::", + [SNMP_TRANS_LOC_STREAM] = "stream::", + [SNMP_TRANS_UDP6] = "udp6::", +}; + +/** + * Try to get a transport identifier which is a leading alphanumeric string + * terminated by a double colon. The string may not be empty. The transport + * identifier is optional. Unknown transport identifiers are reject. + * Be careful: a double colon can also occur in a numeric IPv6 address. * - * [trans::][community@][server][:port] + * \param sc client struct to set errors + * \param strp possible start of transport; updated to point to + * the next character to parse + * + * \return transport identifier */ -int -snmp_parse_server(struct snmp_client *sc, const char *str) +static inline int +get_transp(struct snmp_client *sc, const char **strp) { - const char *p, *s = str; + const char *p; + size_t i; - /* look for a double colon */ - for (p = s; *p != '\0'; p++) { - if (*p == '\\' && p[1] != '\0') { - p++; - continue; + for (i = 0; i < nitems(trans_list); i++) { *** DIFF OUTPUT TRUNCATED AT 1000 LINES *** From owner-svn-src-vendor@freebsd.org Tue Mar 31 17:53:34 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E80B426565E; Tue, 31 Mar 2020 17:53:33 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48sH4W50M2z3QD2; Tue, 31 Mar 2020 17:53:31 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 8D65DE048; Tue, 31 Mar 2020 17:53:24 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02VHrOsu071018; Tue, 31 Mar 2020 17:53:24 GMT (envelope-from harti@FreeBSD.org) Received: (from harti@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02VHrO6v071017; Tue, 31 Mar 2020 17:53:24 GMT (envelope-from harti@FreeBSD.org) Message-Id: <202003311753.02VHrO6v071017@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: harti set sender to harti@FreeBSD.org using -f From: Hartmut Brandt Date: Tue, 31 Mar 2020 17:53:24 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359491 - vendor/1.14 X-SVN-Group: vendor X-SVN-Commit-Author: harti X-SVN-Commit-Paths: vendor/1.14 X-SVN-Commit-Revision: 359491 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 17:53:34 -0000 Author: harti Date: Tue Mar 31 17:53:23 2020 New Revision: 359491 URL: https://svnweb.freebsd.org/changeset/base/359491 Log: Tag import of version 1.14 of bsnmp. Added: vendor/1.14/ - copied from r359490, vendor/bsnmp/dist/ From owner-svn-src-vendor@freebsd.org Tue Mar 31 18:35:43 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id E856B26712E; Tue, 31 Mar 2020 18:35:43 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48sJ1B2Yryz4BPg; Tue, 31 Mar 2020 18:35:42 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id D0ADDE057; Tue, 31 Mar 2020 17:57:11 +0000 (UTC) (envelope-from harti@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 02VHvBQN071296; Tue, 31 Mar 2020 17:57:11 GMT (envelope-from harti@FreeBSD.org) Received: (from harti@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 02VHvB8Q071295; Tue, 31 Mar 2020 17:57:11 GMT (envelope-from harti@FreeBSD.org) Message-Id: <202003311757.02VHvB8Q071295@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: harti set sender to harti@FreeBSD.org using -f From: Hartmut Brandt Date: Tue, 31 Mar 2020 17:57:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359492 - in vendor: 1.14 bsnmp/1.14 X-SVN-Group: vendor X-SVN-Commit-Author: harti X-SVN-Commit-Paths: in vendor: 1.14 bsnmp/1.14 X-SVN-Commit-Revision: 359492 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 31 Mar 2020 18:35:44 -0000 Author: harti Date: Tue Mar 31 17:57:11 2020 New Revision: 359492 URL: https://svnweb.freebsd.org/changeset/base/359492 Log: Move the bsnmp 1.14 import tag to the correct place. Added: vendor/bsnmp/1.14/ - copied from r359491, vendor/1.14/ Deleted: vendor/1.14/ From owner-svn-src-vendor@freebsd.org Thu Apr 2 20:00:44 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 80F6E2629AB; Thu, 2 Apr 2020 20:00:44 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48tYpM6wFJz4Jdg; Thu, 2 Apr 2020 20:00:43 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 878A01F039; Thu, 2 Apr 2020 19:54:36 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 032JsaAs036623; Thu, 2 Apr 2020 19:54:36 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 032JsaVR036622; Thu, 2 Apr 2020 19:54:36 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202004021954.032JsaVR036622@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 2 Apr 2020 19:54:36 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359577 - vendor/llvm-project/llvmorg-10.0.0-0-gd32170dbd5b X-SVN-Group: vendor X-SVN-Commit-Author: dim X-SVN-Commit-Paths: vendor/llvm-project/llvmorg-10.0.0-0-gd32170dbd5b X-SVN-Commit-Revision: 359577 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2020 20:00:44 -0000 Author: dim Date: Thu Apr 2 19:54:35 2020 New Revision: 359577 URL: https://svnweb.freebsd.org/changeset/base/359577 Log: Re-tag llvm-project tag llvmorg-10.0.0-0-gd32170dbd5b (aka 10.0.0 release). Added: vendor/llvm-project/llvmorg-10.0.0-0-gd32170dbd5b/ - copied from r359576, vendor/llvm-project/release-10.x/ From owner-svn-src-vendor@freebsd.org Thu Apr 2 20:00:56 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 916DC262B85; Thu, 2 Apr 2020 20:00:56 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48tYpb56X6z4JpV; Thu, 2 Apr 2020 20:00:55 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id C439C1F037; Thu, 2 Apr 2020 19:54:01 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 032Js1wY036551; Thu, 2 Apr 2020 19:54:01 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 032Js1m3036550; Thu, 2 Apr 2020 19:54:01 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202004021954.032Js1m3036550@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 2 Apr 2020 19:54:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359576 - vendor/llvm-project/llvmorg-10.0.0-0-gd32170dbd5b X-SVN-Group: vendor X-SVN-Commit-Author: dim X-SVN-Commit-Paths: vendor/llvm-project/llvmorg-10.0.0-0-gd32170dbd5b X-SVN-Commit-Revision: 359576 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2020 20:00:56 -0000 Author: dim Date: Thu Apr 2 19:54:01 2020 New Revision: 359576 URL: https://svnweb.freebsd.org/changeset/base/359576 Log: Remove llvm-project tag llvmorg-10.0.0-0-gd32170dbd5b (aka 10.0.0 release), for re-tagging. Deleted: vendor/llvm-project/llvmorg-10.0.0-0-gd32170dbd5b/ From owner-svn-src-vendor@freebsd.org Thu Apr 2 20:01:02 2020 Return-Path: Delivered-To: svn-src-vendor@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 24377262BBC; Thu, 2 Apr 2020 20:01:02 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 48tYpj3Wfbz4JsJ; Thu, 2 Apr 2020 20:01:01 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id B0AD21F034; Thu, 2 Apr 2020 19:52:44 +0000 (UTC) (envelope-from dim@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id 032JqiuU036429; Thu, 2 Apr 2020 19:52:44 GMT (envelope-from dim@FreeBSD.org) Received: (from dim@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id 032JqhQC036423; Thu, 2 Apr 2020 19:52:43 GMT (envelope-from dim@FreeBSD.org) Message-Id: <202004021952.032JqhQC036423@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: dim set sender to dim@FreeBSD.org using -f From: Dimitry Andric Date: Thu, 2 Apr 2020 19:52:43 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org Subject: svn commit: r359575 - in vendor/llvm-project/release-10.x/lldb/bindings: . interface lua python X-SVN-Group: vendor X-SVN-Commit-Author: dim X-SVN-Commit-Paths: in vendor/llvm-project/release-10.x/lldb/bindings: . interface lua python X-SVN-Commit-Revision: 359575 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-vendor@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the vendor work area tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 02 Apr 2020 20:01:02 -0000 Author: dim Date: Thu Apr 2 19:52:43 2020 New Revision: 359575 URL: https://svnweb.freebsd.org/changeset/base/359575 Log: Add lldb/bindings to vendor area, since emaste is going to add support for lldb's lua bindings. Added: vendor/llvm-project/release-10.x/lldb/bindings/ vendor/llvm-project/release-10.x/lldb/bindings/headers.swig vendor/llvm-project/release-10.x/lldb/bindings/interface/ vendor/llvm-project/release-10.x/lldb/bindings/interface/SBAddress.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBAttachInfo.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBlock.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBreakpoint.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBreakpointLocation.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBreakpointName.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBroadcaster.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBCommandInterpreter.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBCommandReturnObject.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBCommunication.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBCompileUnit.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBData.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBDebugger.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBDeclaration.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBError.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBEvent.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBExecutionContext.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBExpressionOptions.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBFile.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBFileSpec.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBFileSpecList.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBFrame.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBFunction.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBHostOS.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBInstruction.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBInstructionList.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBLanguageRuntime.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBLaunchInfo.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBLineEntry.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBListener.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBMemoryRegionInfo.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBMemoryRegionInfoList.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBModule.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBModuleSpec.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBPlatform.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBProcess.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBProcessInfo.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBQueue.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBQueueItem.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBSection.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBSourceManager.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBStream.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBStringList.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBStructuredData.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBSymbol.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBSymbolContext.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBSymbolContextList.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTarget.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBThread.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBThreadCollection.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBThreadPlan.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTrace.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTraceOptions.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBType.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTypeCategory.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTypeEnumMember.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTypeFilter.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTypeFormat.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTypeNameSpecifier.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTypeSummary.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBTypeSynthetic.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBUnixSignals.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBValue.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBValueList.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBVariablesOptions.i vendor/llvm-project/release-10.x/lldb/bindings/interface/SBWatchpoint.i vendor/llvm-project/release-10.x/lldb/bindings/interfaces.swig vendor/llvm-project/release-10.x/lldb/bindings/lua/ vendor/llvm-project/release-10.x/lldb/bindings/lua.swig vendor/llvm-project/release-10.x/lldb/bindings/lua/lua-typemaps.swig vendor/llvm-project/release-10.x/lldb/bindings/macros.swig vendor/llvm-project/release-10.x/lldb/bindings/python/ vendor/llvm-project/release-10.x/lldb/bindings/python.swig vendor/llvm-project/release-10.x/lldb/bindings/python/createPythonInit.py (contents, props changed) vendor/llvm-project/release-10.x/lldb/bindings/python/python-extensions.swig vendor/llvm-project/release-10.x/lldb/bindings/python/python-swigsafecast.swig vendor/llvm-project/release-10.x/lldb/bindings/python/python-typemaps.swig vendor/llvm-project/release-10.x/lldb/bindings/python/python-wrapper.swig Added: vendor/llvm-project/release-10.x/lldb/bindings/headers.swig ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/llvm-project/release-10.x/lldb/bindings/headers.swig Thu Apr 2 19:52:43 2020 (r359575) @@ -0,0 +1,76 @@ +/* C++ headers to be included. */ +%{ +#include +#include +%} + +/* The liblldb header files to be included. */ +%{ +#include "lldb/lldb-public.h" +#include "lldb/API/SBAddress.h" +#include "lldb/API/SBAttachInfo.h" +#include "lldb/API/SBBlock.h" +#include "lldb/API/SBBreakpoint.h" +#include "lldb/API/SBBreakpointLocation.h" +#include "lldb/API/SBBreakpointName.h" +#include "lldb/API/SBBroadcaster.h" +#include "lldb/API/SBCommandInterpreter.h" +#include "lldb/API/SBCommandReturnObject.h" +#include "lldb/API/SBCommunication.h" +#include "lldb/API/SBCompileUnit.h" +#include "lldb/API/SBData.h" +#include "lldb/API/SBDebugger.h" +#include "lldb/API/SBDeclaration.h" +#include "lldb/API/SBError.h" +#include "lldb/API/SBEvent.h" +#include "lldb/API/SBExecutionContext.h" +#include "lldb/API/SBExpressionOptions.h" +#include "lldb/API/SBFileSpec.h" +#include "lldb/API/SBFile.h" +#include "lldb/API/SBFileSpecList.h" +#include "lldb/API/SBFrame.h" +#include "lldb/API/SBFunction.h" +#include "lldb/API/SBHostOS.h" +#include "lldb/API/SBInstruction.h" +#include "lldb/API/SBInstructionList.h" +#include "lldb/API/SBLanguageRuntime.h" +#include "lldb/API/SBLaunchInfo.h" +#include "lldb/API/SBLineEntry.h" +#include "lldb/API/SBListener.h" +#include "lldb/API/SBMemoryRegionInfo.h" +#include "lldb/API/SBMemoryRegionInfoList.h" +#include "lldb/API/SBModule.h" +#include "lldb/API/SBModuleSpec.h" +#include "lldb/API/SBPlatform.h" +#include "lldb/API/SBProcess.h" +#include "lldb/API/SBProcessInfo.h" +#include "lldb/API/SBQueue.h" +#include "lldb/API/SBQueueItem.h" +#include "lldb/API/SBSection.h" +#include "lldb/API/SBSourceManager.h" +#include "lldb/API/SBStream.h" +#include "lldb/API/SBStringList.h" +#include "lldb/API/SBStructuredData.h" +#include "lldb/API/SBSymbol.h" +#include "lldb/API/SBSymbolContext.h" +#include "lldb/API/SBSymbolContextList.h" +#include "lldb/API/SBTarget.h" +#include "lldb/API/SBThread.h" +#include "lldb/API/SBThreadCollection.h" +#include "lldb/API/SBThreadPlan.h" +#include "lldb/API/SBTrace.h" +#include "lldb/API/SBTraceOptions.h" +#include "lldb/API/SBType.h" +#include "lldb/API/SBTypeCategory.h" +#include "lldb/API/SBTypeEnumMember.h" +#include "lldb/API/SBTypeFilter.h" +#include "lldb/API/SBTypeFormat.h" +#include "lldb/API/SBTypeNameSpecifier.h" +#include "lldb/API/SBTypeSummary.h" +#include "lldb/API/SBTypeSynthetic.h" +#include "lldb/API/SBValue.h" +#include "lldb/API/SBValueList.h" +#include "lldb/API/SBVariablesOptions.h" +#include "lldb/API/SBWatchpoint.h" +#include "lldb/API/SBUnixSignals.h" +%} Added: vendor/llvm-project/release-10.x/lldb/bindings/interface/SBAddress.i ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/llvm-project/release-10.x/lldb/bindings/interface/SBAddress.i Thu Apr 2 19:52:43 2020 (r359575) @@ -0,0 +1,185 @@ +//===-- SWIG Interface for SBAddress ----------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"A section + offset based address class. + +The SBAddress class allows addresses to be relative to a section +that can move during runtime due to images (executables, shared +libraries, bundles, frameworks) being loaded at different +addresses than the addresses found in the object file that +represents them on disk. There are currently two types of addresses +for a section: + o file addresses + o load addresses + +File addresses represents the virtual addresses that are in the 'on +disk' object files. These virtual addresses are converted to be +relative to unique sections scoped to the object file so that +when/if the addresses slide when the images are loaded/unloaded +in memory, we can easily track these changes without having to +update every object (compile unit ranges, line tables, function +address ranges, lexical block and inlined subroutine address +ranges, global and static variables) each time an image is loaded or +unloaded. + +Load addresses represents the virtual addresses where each section +ends up getting loaded at runtime. Before executing a program, it +is common for all of the load addresses to be unresolved. When a +DynamicLoader plug-in receives notification that shared libraries +have been loaded/unloaded, the load addresses of the main executable +and any images (shared libraries) will be resolved/unresolved. When +this happens, breakpoints that are in one of these sections can be +set/cleared. + +See docstring of SBFunction for example usage of SBAddress." +) SBAddress; +class SBAddress +{ +public: + + SBAddress (); + + SBAddress (const lldb::SBAddress &rhs); + + SBAddress (lldb::SBSection section, + lldb::addr_t offset); + + %feature("docstring", " + Create an address by resolving a load address using the supplied target.") SBAddress; + SBAddress (lldb::addr_t load_addr, lldb::SBTarget &target); + + ~SBAddress (); + + bool + IsValid () const; + + explicit operator bool() const; + +#ifdef SWIGPYTHON + // operator== is a free function, which swig does not handle, so we inject + // our own equality operator here + %pythoncode%{ + def __eq__(self, other): + return not self.__ne__(other) + %} +#endif + + bool operator!=(const SBAddress &rhs) const; + + void + Clear (); + + addr_t + GetFileAddress () const; + + addr_t + GetLoadAddress (const lldb::SBTarget &target) const; + + void + SetLoadAddress (lldb::addr_t load_addr, + lldb::SBTarget &target); + + bool + OffsetAddress (addr_t offset); + + bool + GetDescription (lldb::SBStream &description); + + lldb::SBSection + GetSection (); + + lldb::addr_t + SBAddress::GetOffset (); + + void + SetAddress (lldb::SBSection section, + lldb::addr_t offset); + + %feature("docstring", " + GetSymbolContext() and the following can lookup symbol information for a given address. + An address might refer to code or data from an existing module, or it + might refer to something on the stack or heap. The following functions + will only return valid values if the address has been resolved to a code + or data address using 'void SBAddress::SetLoadAddress(...)' or + 'lldb::SBAddress SBTarget::ResolveLoadAddress (...)'.") GetSymbolContext; + lldb::SBSymbolContext + GetSymbolContext (uint32_t resolve_scope); + + %feature("docstring", " + GetModule() and the following grab individual objects for a given address and + are less efficient if you want more than one symbol related objects. + Use one of the following when you want multiple debug symbol related + objects for an address: + lldb::SBSymbolContext SBAddress::GetSymbolContext (uint32_t resolve_scope); + lldb::SBSymbolContext SBTarget::ResolveSymbolContextForAddress (const SBAddress &addr, uint32_t resolve_scope); + One or more bits from the SymbolContextItem enumerations can be logically + OR'ed together to more efficiently retrieve multiple symbol objects.") GetModule; + lldb::SBModule + GetModule (); + + lldb::SBCompileUnit + GetCompileUnit (); + + lldb::SBFunction + GetFunction (); + + lldb::SBBlock + GetBlock (); + + lldb::SBSymbol + GetSymbol (); + + lldb::SBLineEntry + GetLineEntry (); + + STRING_EXTENSION(SBAddress) + +#ifdef SWIGPYTHON + %pythoncode %{ + def __get_load_addr_property__ (self): + '''Get the load address for a lldb.SBAddress using the current target.''' + return self.GetLoadAddress (target) + + def __set_load_addr_property__ (self, load_addr): + '''Set the load address for a lldb.SBAddress using the current target.''' + return self.SetLoadAddress (load_addr, target) + + def __int__(self): + '''Convert an address to a load address if there is a process and that process is alive, or to a file address otherwise.''' + if process.is_alive: + return self.GetLoadAddress (target) + else: + return self.GetFileAddress () + + def __oct__(self): + '''Convert the address to an octal string''' + return '%o' % int(self) + + def __hex__(self): + '''Convert the address to an hex string''' + return '0x%x' % int(self) + + module = property(GetModule, None, doc='''A read only property that returns an lldb object that represents the module (lldb.SBModule) that this address resides within.''') + compile_unit = property(GetCompileUnit, None, doc='''A read only property that returns an lldb object that represents the compile unit (lldb.SBCompileUnit) that this address resides within.''') + line_entry = property(GetLineEntry, None, doc='''A read only property that returns an lldb object that represents the line entry (lldb.SBLineEntry) that this address resides within.''') + function = property(GetFunction, None, doc='''A read only property that returns an lldb object that represents the function (lldb.SBFunction) that this address resides within.''') + block = property(GetBlock, None, doc='''A read only property that returns an lldb object that represents the block (lldb.SBBlock) that this address resides within.''') + symbol = property(GetSymbol, None, doc='''A read only property that returns an lldb object that represents the symbol (lldb.SBSymbol) that this address resides within.''') + offset = property(GetOffset, None, doc='''A read only property that returns the section offset in bytes as an integer.''') + section = property(GetSection, None, doc='''A read only property that returns an lldb object that represents the section (lldb.SBSection) that this address resides within.''') + file_addr = property(GetFileAddress, None, doc='''A read only property that returns file address for the section as an integer. This is the address that represents the address as it is found in the object file that defines it.''') + load_addr = property(__get_load_addr_property__, __set_load_addr_property__, doc='''A read/write property that gets/sets the SBAddress using load address. The setter resolves SBAddress using the SBTarget from lldb.target so this property can ONLY be used in the interactive script interpreter (i.e. under the lldb script command) and not in Python based commands, or breakpoint commands.''') + %} +#endif + +}; + +} // namespace lldb Added: vendor/llvm-project/release-10.x/lldb/bindings/interface/SBAttachInfo.i ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/llvm-project/release-10.x/lldb/bindings/interface/SBAttachInfo.i Thu Apr 2 19:52:43 2020 (r359575) @@ -0,0 +1,115 @@ +//===-- SWIG Interface for SBAttachInfo--------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +class SBAttachInfo +{ +public: + SBAttachInfo (); + + SBAttachInfo (lldb::pid_t pid); + + SBAttachInfo (const char *path, bool wait_for); + + SBAttachInfo (const char *path, bool wait_for, bool async); + + SBAttachInfo (const lldb::SBAttachInfo &rhs); + + lldb::pid_t + GetProcessID (); + + void + SetProcessID (lldb::pid_t pid); + + void + SetExecutable (const char *path); + + void + SetExecutable (lldb::SBFileSpec exe_file); + + bool + GetWaitForLaunch (); + + void + SetWaitForLaunch (bool b); + + void + SetWaitForLaunch (bool b, bool async); + + bool + GetIgnoreExisting (); + + void + SetIgnoreExisting (bool b); + + uint32_t + GetResumeCount (); + + void + SetResumeCount (uint32_t c); + + const char * + GetProcessPluginName (); + + void + SetProcessPluginName (const char *plugin_name); + + uint32_t + GetUserID(); + + uint32_t + GetGroupID(); + + bool + UserIDIsValid (); + + bool + GroupIDIsValid (); + + void + SetUserID (uint32_t uid); + + void + SetGroupID (uint32_t gid); + + uint32_t + GetEffectiveUserID(); + + uint32_t + GetEffectiveGroupID(); + + bool + EffectiveUserIDIsValid (); + + bool + EffectiveGroupIDIsValid (); + + void + SetEffectiveUserID (uint32_t uid); + + void + SetEffectiveGroupID (uint32_t gid); + + lldb::pid_t + GetParentProcessID (); + + void + SetParentProcessID (lldb::pid_t pid); + + bool + ParentProcessIDIsValid(); + + lldb::SBListener + GetListener (); + + void + SetListener (lldb::SBListener &listener); +}; + +} // namespace lldb Added: vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBlock.i ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBlock.i Thu Apr 2 19:52:43 2020 (r359575) @@ -0,0 +1,163 @@ +//===-- SWIG Interface for SBBlock ------------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents a lexical block. SBFunction contains SBBlock(s)." +) SBBlock; +class SBBlock +{ +public: + + SBBlock (); + + SBBlock (const lldb::SBBlock &rhs); + + ~SBBlock (); + + %feature("docstring", + "Does this block represent an inlined function?" + ) IsInlined; + bool + IsInlined () const; + + bool + IsValid () const; + + explicit operator bool() const; + + %feature("docstring", " + Get the function name if this block represents an inlined function; + otherwise, return None.") GetInlinedName; + const char * + GetInlinedName () const; + + %feature("docstring", " + Get the call site file if this block represents an inlined function; + otherwise, return an invalid file spec.") GetInlinedCallSiteFile; + lldb::SBFileSpec + GetInlinedCallSiteFile () const; + + %feature("docstring", " + Get the call site line if this block represents an inlined function; + otherwise, return 0.") GetInlinedCallSiteLine; + uint32_t + GetInlinedCallSiteLine () const; + + %feature("docstring", " + Get the call site column if this block represents an inlined function; + otherwise, return 0.") GetInlinedCallSiteColumn; + uint32_t + GetInlinedCallSiteColumn () const; + + %feature("docstring", "Get the parent block.") GetParent; + lldb::SBBlock + GetParent (); + + %feature("docstring", "Get the inlined block that is or contains this block.") GetContainingInlinedBlock; + lldb::SBBlock + GetContainingInlinedBlock (); + + %feature("docstring", "Get the sibling block for this block.") GetSibling; + lldb::SBBlock + GetSibling (); + + %feature("docstring", "Get the first child block.") GetFirstChild; + lldb::SBBlock + GetFirstChild (); + + uint32_t + GetNumRanges (); + + lldb::SBAddress + GetRangeStartAddress (uint32_t idx); + + lldb::SBAddress + GetRangeEndAddress (uint32_t idx); + + uint32_t + GetRangeIndexForBlockAddress (lldb::SBAddress block_addr); + + bool + GetDescription (lldb::SBStream &description); + + lldb::SBValueList + GetVariables (lldb::SBFrame& frame, + bool arguments, + bool locals, + bool statics, + lldb::DynamicValueType use_dynamic); + + lldb::SBValueList + GetVariables (lldb::SBTarget& target, + bool arguments, + bool locals, + bool statics); + + STRING_EXTENSION(SBBlock) + +#ifdef SWIGPYTHON + %pythoncode %{ + def get_range_at_index(self, idx): + if idx < self.GetNumRanges(): + return [self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)] + return [] + + class ranges_access(object): + '''A helper object that will lazily hand out an array of lldb.SBAddress that represent address ranges for a block.''' + def __init__(self, sbblock): + self.sbblock = sbblock + + def __len__(self): + if self.sbblock: + return int(self.sbblock.GetNumRanges()) + return 0 + + def __getitem__(self, key): + count = len(self) + if type(key) is int: + return self.sbblock.get_range_at_index (key); + if isinstance(key, SBAddress): + range_idx = self.sbblock.GetRangeIndexForBlockAddress(key); + if range_idx < len(self): + return [self.sbblock.GetRangeStartAddress(range_idx), self.sbblock.GetRangeEndAddress(range_idx)] + else: + print("error: unsupported item type: %s" % type(key)) + return None + + def get_ranges_access_object(self): + '''An accessor function that returns a ranges_access() object which allows lazy block address ranges access.''' + return self.ranges_access (self) + + def get_ranges_array(self): + '''An accessor function that returns an array object that contains all ranges in this block object.''' + if not hasattr(self, 'ranges_array'): + self.ranges_array = [] + for idx in range(self.num_ranges): + self.ranges_array.append ([self.GetRangeStartAddress(idx), self.GetRangeEndAddress(idx)]) + return self.ranges_array + + def get_call_site(self): + return declaration(self.GetInlinedCallSiteFile(), self.GetInlinedCallSiteLine(), self.GetInlinedCallSiteColumn()) + + parent = property(GetParent, None, doc='''A read only property that returns the same result as GetParent().''') + first_child = property(GetFirstChild, None, doc='''A read only property that returns the same result as GetFirstChild().''') + call_site = property(get_call_site, None, doc='''A read only property that returns a lldb.declaration object that contains the inlined call site file, line and column.''') + sibling = property(GetSibling, None, doc='''A read only property that returns the same result as GetSibling().''') + name = property(GetInlinedName, None, doc='''A read only property that returns the same result as GetInlinedName().''') + inlined_block = property(GetContainingInlinedBlock, None, doc='''A read only property that returns the same result as GetContainingInlinedBlock().''') + range = property(get_ranges_access_object, None, doc='''A read only property that allows item access to the address ranges for a block by integer (range = block.range[0]) and by lldb.SBAdddress (find the range that contains the specified lldb.SBAddress like "pc_range = lldb.frame.block.range[frame.addr]").''') + ranges = property(get_ranges_array, None, doc='''A read only property that returns a list() object that contains all of the address ranges for the block.''') + num_ranges = property(GetNumRanges, None, doc='''A read only property that returns the same result as GetNumRanges().''') + %} +#endif + +}; + +} // namespace lldb Added: vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBreakpoint.i ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBreakpoint.i Thu Apr 2 19:52:43 2020 (r359575) @@ -0,0 +1,334 @@ +//===-- SWIG Interface for SBBreakpoint -------------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +namespace lldb { + +%feature("docstring", +"Represents a logical breakpoint and its associated settings. + +For example (from test/functionalities/breakpoint/breakpoint_ignore_count/ +TestBreakpointIgnoreCount.py), + + def breakpoint_ignore_count_python(self): + '''Use Python APIs to set breakpoint ignore count.''' + exe = os.path.join(os.getcwd(), 'a.out') + + # Create a target by the debugger. + target = self.dbg.CreateTarget(exe) + self.assertTrue(target, VALID_TARGET) + + # Now create a breakpoint on main.c by name 'c'. + breakpoint = target.BreakpointCreateByName('c', 'a.out') + self.assertTrue(breakpoint and + breakpoint.GetNumLocations() == 1, + VALID_BREAKPOINT) + + # Get the breakpoint location from breakpoint after we verified that, + # indeed, it has one location. + location = breakpoint.GetLocationAtIndex(0) + self.assertTrue(location and + location.IsEnabled(), + VALID_BREAKPOINT_LOCATION) + + # Set the ignore count on the breakpoint location. + location.SetIgnoreCount(2) + self.assertTrue(location.GetIgnoreCount() == 2, + 'SetIgnoreCount() works correctly') + + # Now launch the process, and do not stop at entry point. + process = target.LaunchSimple(None, None, os.getcwd()) + self.assertTrue(process, PROCESS_IS_VALID) + + # Frame#0 should be on main.c:37, frame#1 should be on main.c:25, and + # frame#2 should be on main.c:48. + #lldbutil.print_stacktraces(process) + from lldbutil import get_stopped_thread + thread = get_stopped_thread(process, lldb.eStopReasonBreakpoint) + self.assertTrue(thread != None, 'There should be a thread stopped due to breakpoint') + frame0 = thread.GetFrameAtIndex(0) + frame1 = thread.GetFrameAtIndex(1) + frame2 = thread.GetFrameAtIndex(2) + self.assertTrue(frame0.GetLineEntry().GetLine() == self.line1 and + frame1.GetLineEntry().GetLine() == self.line3 and + frame2.GetLineEntry().GetLine() == self.line4, + STOPPED_DUE_TO_BREAKPOINT_IGNORE_COUNT) + + # The hit count for the breakpoint should be 3. + self.assertTrue(breakpoint.GetHitCount() == 3) + + process.Continue() + +SBBreakpoint supports breakpoint location iteration, for example, + + for bl in breakpoint: + print('breakpoint location load addr: %s' % hex(bl.GetLoadAddress())) + print('breakpoint location condition: %s' % hex(bl.GetCondition())) + +and rich comparison methods which allow the API program to use, + + if aBreakpoint == bBreakpoint: + ... + +to compare two breakpoints for equality." +) SBBreakpoint; +class SBBreakpoint +{ +public: + + SBBreakpoint (); + + SBBreakpoint (const lldb::SBBreakpoint& rhs); + + ~SBBreakpoint(); + + bool operator==(const lldb::SBBreakpoint &rhs); + + bool operator!=(const lldb::SBBreakpoint &rhs); + + break_id_t + GetID () const; + + bool + IsValid() const; + + explicit operator bool() const; + + void + ClearAllBreakpointSites (); + + lldb::SBBreakpointLocation + FindLocationByAddress (lldb::addr_t vm_addr); + + lldb::break_id_t + FindLocationIDByAddress (lldb::addr_t vm_addr); + + lldb::SBBreakpointLocation + FindLocationByID (lldb::break_id_t bp_loc_id); + + lldb::SBBreakpointLocation + GetLocationAtIndex (uint32_t index); + + void + SetEnabled (bool enable); + + bool + IsEnabled (); + + void + SetOneShot (bool one_shot); + + bool + IsOneShot (); + + bool + IsInternal (); + + uint32_t + GetHitCount () const; + + void + SetIgnoreCount (uint32_t count); + + uint32_t + GetIgnoreCount () const; + + %feature("docstring", " + The breakpoint stops only if the condition expression evaluates to true.") SetCondition; + void + SetCondition (const char *condition); + + %feature("docstring", " + Get the condition expression for the breakpoint.") GetCondition; + const char * + GetCondition (); + + void SetAutoContinue(bool auto_continue); + + bool GetAutoContinue(); + + void + SetThreadID (lldb::tid_t sb_thread_id); + + lldb::tid_t + GetThreadID (); + + void + SetThreadIndex (uint32_t index); + + uint32_t + GetThreadIndex() const; + + void + SetThreadName (const char *thread_name); + + const char * + GetThreadName () const; + + void + SetQueueName (const char *queue_name); + + const char * + GetQueueName () const; + + %feature("docstring", " + Set the name of the script function to be called when the breakpoint is hit.") SetScriptCallbackFunction; + void + SetScriptCallbackFunction (const char *callback_function_name); + + %feature("docstring", " + Set the name of the script function to be called when the breakpoint is hit. + To use this variant, the function should take (frame, bp_loc, extra_args, dict) and + when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction; + SBError + SetScriptCallbackFunction (const char *callback_function_name, + SBStructuredData &extra_args); + + %feature("docstring", " + Provide the body for the script function to be called when the breakpoint is hit. + The body will be wrapped in a function, which be passed two arguments: + 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint + 'bpno' - which is the SBBreakpointLocation to which the callback was attached. + + The error parameter is currently ignored, but will at some point hold the Python + compilation diagnostics. + Returns true if the body compiles successfully, false if not.") SetScriptCallbackBody; + SBError + SetScriptCallbackBody (const char *script_body_text); + + void SetCommandLineCommands(SBStringList &commands); + + bool GetCommandLineCommands(SBStringList &commands); + + bool + AddName (const char *new_name); + + void + RemoveName (const char *name_to_remove); + + bool + MatchesName (const char *name); + + void + GetNames (SBStringList &names); + + size_t + GetNumResolvedLocations() const; + + size_t + GetNumLocations() const; + + bool + GetDescription (lldb::SBStream &description); + + bool + GetDescription(lldb::SBStream &description, bool include_locations); + + // Can only be called from a ScriptedBreakpointResolver... + SBError + AddLocation(SBAddress &address); + + static bool + EventIsBreakpointEvent (const lldb::SBEvent &event); + + static lldb::BreakpointEventType + GetBreakpointEventTypeFromEvent (const lldb::SBEvent& event); + + static lldb::SBBreakpoint + GetBreakpointFromEvent (const lldb::SBEvent& event); + + static lldb::SBBreakpointLocation + GetBreakpointLocationAtIndexFromEvent (const lldb::SBEvent& event, uint32_t loc_idx); + + static uint32_t + GetNumBreakpointLocationsFromEvent (const lldb::SBEvent &event_sp); + + bool + IsHardware (); + + STRING_EXTENSION(SBBreakpoint) + +#ifdef SWIGPYTHON + %pythoncode %{ + + class locations_access(object): + '''A helper object that will lazily hand out locations for a breakpoint when supplied an index.''' + def __init__(self, sbbreakpoint): + self.sbbreakpoint = sbbreakpoint + + def __len__(self): + if self.sbbreakpoint: + return int(self.sbbreakpoint.GetNumLocations()) + return 0 + + def __getitem__(self, key): + if type(key) is int and key < len(self): + return self.sbbreakpoint.GetLocationAtIndex(key) + return None + + def get_locations_access_object(self): + '''An accessor function that returns a locations_access() object which allows lazy location access from a lldb.SBBreakpoint object.''' + return self.locations_access (self) + + def get_breakpoint_location_list(self): + '''An accessor function that returns a list() that contains all locations in a lldb.SBBreakpoint object.''' + locations = [] + accessor = self.get_locations_access_object() + for idx in range(len(accessor)): + locations.append(accessor[idx]) + return locations + + def __iter__(self): + '''Iterate over all breakpoint locations in a lldb.SBBreakpoint + object.''' + return lldb_iter(self, 'GetNumLocations', 'GetLocationAtIndex') + + def __len__(self): + '''Return the number of breakpoint locations in a lldb.SBBreakpoint + object.''' + return self.GetNumLocations() + + locations = property(get_breakpoint_location_list, None, doc='''A read only property that returns a list() of lldb.SBBreakpointLocation objects for this breakpoint.''') + location = property(get_locations_access_object, None, doc='''A read only property that returns an object that can access locations by index (not location ID) (location = bkpt.location[12]).''') + id = property(GetID, None, doc='''A read only property that returns the ID of this breakpoint.''') + enabled = property(IsEnabled, SetEnabled, doc='''A read/write property that configures whether this breakpoint is enabled or not.''') + one_shot = property(IsOneShot, SetOneShot, doc='''A read/write property that configures whether this breakpoint is one-shot (deleted when hit) or not.''') + num_locations = property(GetNumLocations, None, doc='''A read only property that returns the count of locations of this breakpoint.''') + %} +#endif + + +}; + +class SBBreakpointListImpl; + +class LLDB_API SBBreakpointList +{ +public: + SBBreakpointList(SBTarget &target); + + ~SBBreakpointList(); + + size_t GetSize() const; + + SBBreakpoint + GetBreakpointAtIndex(size_t idx); + + SBBreakpoint + FindBreakpointByID(lldb::break_id_t); + + void Append(const SBBreakpoint &sb_bkpt); + + bool AppendIfUnique(const SBBreakpoint &sb_bkpt); + + void AppendByID (lldb::break_id_t id); + + void Clear(); +private: + std::shared_ptr m_opaque_sp; +}; + +} // namespace lldb Added: vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBreakpointLocation.i ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ vendor/llvm-project/release-10.x/lldb/bindings/interface/SBBreakpointLocation.i Thu Apr 2 19:52:43 2020 (r359575) @@ -0,0 +1,141 @@ +//===-- SWIG Interface for SBBreakpointLocation -----------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +namespace lldb { + +%feature("docstring", +"Represents one unique instance (by address) of a logical breakpoint. + +A breakpoint location is defined by the breakpoint that produces it, +and the address that resulted in this particular instantiation. +Each breakpoint location has its settable options. + +SBBreakpoint contains SBBreakpointLocation(s). See docstring of SBBreakpoint +for retrieval of an SBBreakpointLocation from an SBBreakpoint." +) SBBreakpointLocation; +class SBBreakpointLocation +{ +public: + + SBBreakpointLocation (); + + SBBreakpointLocation (const lldb::SBBreakpointLocation &rhs); + + ~SBBreakpointLocation (); + + break_id_t + GetID (); + + bool + IsValid() const; + + explicit operator bool() const; + + lldb::SBAddress + GetAddress(); + + lldb::addr_t + GetLoadAddress (); + + void + SetEnabled(bool enabled); + + bool + IsEnabled (); + + uint32_t + GetHitCount (); + + uint32_t + GetIgnoreCount (); + + void + SetIgnoreCount (uint32_t n); + + %feature("docstring", " + The breakpoint location stops only if the condition expression evaluates + to true.") SetCondition; + void + SetCondition (const char *condition); + + %feature("docstring", " + Get the condition expression for the breakpoint location.") GetCondition; + const char * + GetCondition (); + + bool GetAutoContinue(); + + void SetAutoContinue(bool auto_continue); + + %feature("docstring", " + Set the callback to the given Python function name. + The function takes three arguments (frame, bp_loc, dict).") SetScriptCallbackFunction; + void + SetScriptCallbackFunction (const char *callback_function_name); + + %feature("docstring", " + Set the name of the script function to be called when the breakpoint is hit. + To use this variant, the function should take (frame, bp_loc, extra_args, dict) and + when the breakpoint is hit the extra_args will be passed to the callback function.") SetScriptCallbackFunction; + SBError + SetScriptCallbackFunction (const char *callback_function_name, + SBStructuredData &extra_args); + + %feature("docstring", " + Provide the body for the script function to be called when the breakpoint location is hit. + The body will be wrapped in a function, which be passed two arguments: + 'frame' - which holds the bottom-most SBFrame of the thread that hit the breakpoint + 'bpno' - which is the SBBreakpointLocation to which the callback was attached. + + The error parameter is currently ignored, but will at some point hold the Python + compilation diagnostics. + Returns true if the body compiles successfully, false if not.") SetScriptCallbackBody; + SBError + SetScriptCallbackBody (const char *script_body_text); + + void SetCommandLineCommands(SBStringList &commands); + + bool GetCommandLineCommands(SBStringList &commands); + + void + SetThreadID (lldb::tid_t sb_thread_id); + + lldb::tid_t + GetThreadID (); *** DIFF OUTPUT TRUNCATED AT 1000 LINES ***