Harald Welte | 30afef3 | 2015-08-30 12:28:29 +0200 | [diff] [blame^] | 1 | |
2 | #include <string.h> | ||||
3 | |||||
4 | #include <asn1defs.h> | ||||
5 | |||||
6 | #include "asn1helpers.h" | ||||
7 | |||||
8 | int asn1_strncpy(char *out, const ASN1String *in, size_t n) | ||||
9 | { | ||||
10 | size_t cpylen = n; | ||||
11 | |||||
12 | if (in->len < cpylen) | ||||
13 | cpylen = in->len; | ||||
14 | |||||
15 | strncpy(out, (char *)in->buf, cpylen); | ||||
16 | out[n-1] = '\0'; | ||||
17 | |||||
18 | return cpylen; | ||||
19 | } |