summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/regress/lib/libcrypto/asn1/asn1object.c41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/regress/lib/libcrypto/asn1/asn1object.c b/src/regress/lib/libcrypto/asn1/asn1object.c
index 56382a4edc..0660f8af7d 100644
--- a/src/regress/lib/libcrypto/asn1/asn1object.c
+++ b/src/regress/lib/libcrypto/asn1/asn1object.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: asn1object.c,v 1.11 2024/05/29 16:19:50 tb Exp $ */ 1/* $OpenBSD: asn1object.c,v 1.12 2024/05/29 16:47:26 tb Exp $ */
2/* 2/*
3 * Copyright (c) 2017, 2021, 2022 Joel Sing <jsing@openbsd.org> 3 * Copyright (c) 2017, 2021, 2022 Joel Sing <jsing@openbsd.org>
4 * 4 *
@@ -17,6 +17,7 @@
17 17
18#include <openssl/asn1.h> 18#include <openssl/asn1.h>
19#include <openssl/err.h> 19#include <openssl/err.h>
20#include <openssl/objects.h>
20 21
21#include <err.h> 22#include <err.h>
22#include <stdio.h> 23#include <stdio.h>
@@ -505,6 +506,43 @@ asn1_object_large_oid_test(void)
505 return failed; 506 return failed;
506} 507}
507 508
509static int
510asn1_object_i2d_errors(void)
511{
512 ASN1_OBJECT *aobj = NULL;
513 int ret;
514 int failed = 1;
515
516 if ((ret = i2d_ASN1_OBJECT(NULL, NULL)) > 0) {
517 fprintf(stderr, "FAIL: i2d_ASN1_OBJECT(NULL, NULL) returned %d, "
518 "want <= 0\n", ret);
519 goto failed;
520 }
521
522 if ((aobj = OBJ_nid2obj(NID_undef)) == NULL) {
523 fprintf(stderr, "FAIL: OBJ_nid2obj() failed\n");
524 goto failed;
525 }
526
527 if (OBJ_get0_data(aobj) != NULL) {
528 fprintf(stderr, "FAIL: undefined obj didn't have NULL data\n");
529 goto failed;
530 }
531
532 if ((ret = i2d_ASN1_OBJECT(aobj, NULL)) > 0) {
533 fprintf(stderr, "FAIL: i2d_ASN1_OBJECT() succeeded on undefined "
534 "object\n");
535 goto failed;
536 }
537
538 failed = 0;
539
540 failed:
541 ASN1_OBJECT_free(aobj);
542
543 return failed;
544}
545
508int 546int
509main(int argc, char **argv) 547main(int argc, char **argv)
510{ 548{
@@ -514,6 +552,7 @@ main(int argc, char **argv)
514 failed |= asn1_object_bad_content_test(); 552 failed |= asn1_object_bad_content_test();
515 failed |= asn1_object_txt_test(); 553 failed |= asn1_object_txt_test();
516 failed |= asn1_object_large_oid_test(); 554 failed |= asn1_object_large_oid_test();
555 failed |= asn1_object_i2d_errors();
517 556
518 return (failed); 557 return (failed);
519} 558}