aboutsummaryrefslogtreecommitdiffstats
path: root/src/asn1helpers.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/asn1helpers.c')
-rw-r--r--src/asn1helpers.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/asn1helpers.c b/src/asn1helpers.c
new file mode 100644
index 0000000..fe886e3
--- /dev/null
+++ b/src/asn1helpers.c
@@ -0,0 +1,19 @@
+
+#include <string.h>
+
+#include <asn1defs.h>
+
+#include "asn1helpers.h"
+
+int asn1_strncpy(char *out, const ASN1String *in, size_t n)
+{
+ size_t cpylen = n;
+
+ if (in->len < cpylen)
+ cpylen = in->len;
+
+ strncpy(out, (char *)in->buf, cpylen);
+ out[n-1] = '\0';
+
+ return cpylen;
+}