shithub: riscv

Download patch

ref: deae8939583d83fd798fca97665e0e94656c3ee8
parent: 469438f4dfe9f97ab7d7a59c3e9c80b99ef4be7f
author: Ori Bernstein <ori@eigenstate.org>
date: Mon Apr 21 21:46:58 EDT 2025

libsec: never return nil from octet_decode

when we got a string in constructed form with
a determinate length, we could return a nil
string unexpectedly; this makes us construct
an empty string in this case.

--- a/sys/src/libsec/port/x509.c
+++ b/sys/src/libsec/port/x509.c
@@ -705,7 +705,8 @@
 		if(err != ASN_OK){
 			freebytes(ans);
 			ans = nil;
-		}
+		} else if(ans == nil)
+			ans = newbytes(0);
 	}
 	*pp = p;
 	*pbytes = ans;
--