Test OBJ_obj2txt() with NULL and short buffers.
authorjsing <jsing@openbsd.org>
Sun, 20 Feb 2022 13:47:53 +0000 (13:47 +0000)
committerjsing <jsing@openbsd.org>
Sun, 20 Feb 2022 13:47:53 +0000 (13:47 +0000)
regress/lib/libcrypto/objects/objectstest.c

index 9f28b63..597373e 100644 (file)
@@ -1,4 +1,4 @@
-/* $OpenBSD: objectstest.c,v 1.4 2022/02/12 12:42:19 jsing Exp $ */
+/* $OpenBSD: objectstest.c,v 1.5 2022/02/20 13:47:53 jsing Exp $ */
 /*
  * Copyright (c) 2017, 2022 Joel Sing <jsing@openbsd.org>
  *
@@ -290,6 +290,17 @@ obj_oid_test(struct obj_test *ot)
                goto failed;
        }
 
+       if ((OBJ_obj2txt(NULL, 0, obj, 1) != len)) {
+               fprintf(stderr, "FAIL: OBJ_obj2txt() with NULL buffer != %d\n",
+                   len);
+               goto failed;
+       }
+       if ((OBJ_obj2txt(buf, 3, obj, 1) != len)) {
+               fprintf(stderr, "FAIL: OBJ_obj2txt() with short buffer != %d\n",
+                   len);
+               goto failed;
+       }
+
        failed = 0;
 
  failed: