problem fixed
diff --git a/skeletons/BMPString.c b/skeletons/BMPString.c
index 1bfb174..d6a9308 100644
--- a/skeletons/BMPString.c
+++ b/skeletons/BMPString.c
@@ -111,7 +111,7 @@
if(1) {
/* Swap byte order and trim encoding to 2 bytes */
uint32_t *wc = wcs;
- uint32_t *wc_end = wcs + wcs_len + 1;
+ uint32_t *wc_end = wcs + wcs_len;
uint16_t *dstwc = (uint16_t *)wcs;
for(; wc < wc_end; wc++, dstwc++) {
uint32_t wch = *wc;
@@ -131,6 +131,7 @@
rc.consumed = 0;
return rc;
} else {
+ dstwc[2 * wcs_len] = 0;
wcs = (uint32_t *)dstwc;
}
}
diff --git a/skeletons/UTF8String.c b/skeletons/UTF8String.c
index 3cd574d..e3f7388 100644
--- a/skeletons/UTF8String.c
+++ b/skeletons/UTF8String.c
@@ -1,5 +1,6 @@
/*-
- * Copyright (c) 2003, 2004 Lev Walkin <vlm@lionet.info>. All rights reserved.
+ * Copyright (c) 2003, 2004, 2006 Lev Walkin <vlm@lionet.info>.
+ * All rights reserved.
* Redistribution and modifications are permitted subject to BSD license.
*/
#include <asn_internal.h>
@@ -103,6 +104,7 @@
size_t length;
uint8_t *buf = st->buf;
uint8_t *end = buf + st->size;
+ uint32_t *dstend = dst + dstlen;
for(length = 0; buf < end; length++) {
int ch = *buf;
@@ -127,7 +129,7 @@
/* Check character sequence length */
if(buf + want > end) return U8E_TRUNC;
- value = ch & (0xff >> (want + 1));
+ value = ch & (0xff >> want);
cend = buf + want;
for(buf++; buf < cend; buf++) {
ch = *buf;
@@ -136,10 +138,11 @@
}
if(value < UTF8String_mv[want])
return U8E_NOTMIN;
- if(dstlen) *dst++ = value; /* Record value */
+ if(dst < dstend)
+ *dst++ = value; /* Record value */
}
- if(dstlen) *dst = 0; /* zero-terminate */
+ if(dst < dstend) *dst = 0; /* zero-terminate */
return length;
}