diff options
author | Stefan Eßer <se@FreeBSD.org> | 2020-10-30 14:32:13 +0000 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2020-10-30 14:32:13 +0000 |
commit | 6bdb89a898e55a6c7fba7122b4928838ebab7fa0 (patch) | |
tree | 1e20648ea69dce77be966d2349afe392b02e4976 /usr.bin/calendar/events.c | |
parent | 7c58c37ebba41069c8acbfc1cceb4eea6585a103 (diff) |
Fix length calculation in memmove
MFC after: 3 days
Notes
Notes:
svn path=/head/; revision=367166
Diffstat (limited to 'usr.bin/calendar/events.c')
-rw-r--r-- | usr.bin/calendar/events.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/calendar/events.c b/usr.bin/calendar/events.c index 39ede509e4db..1275c66dca12 100644 --- a/usr.bin/calendar/events.c +++ b/usr.bin/calendar/events.c @@ -55,6 +55,7 @@ set_new_encoding(void) const char *newenc; newenc = nl_langinfo(CODESET); + fprintf(stderr, "NEWENC=%s\n", newenc); // DEBUG if (currentEncoding == NULL) { currentEncoding = strdup(newenc); if (currentEncoding == NULL) @@ -98,13 +99,14 @@ convert(char *input) else err(1, "Initialization failure"); } + fprintf(stderr, "CONV=%p\n", conv); // DEBUG } inleft = strlen(input); inbuf = input; - outlen = inleft; - if ((output = malloc(outlen + 1)) == NULL) + outlen = inleft + 3; + if ((output = malloc(outlen)) == NULL) errx(1, "convert: cannot allocate memory"); for (;;) { @@ -112,7 +114,9 @@ convert(char *input) outbuf = output + converted; outleft = outlen - converted; + fprintf(stderr, "-< %s %p %ld %ld\n", inbuf, outbuf, inleft, outleft); // DEBUG converted = iconv(conv, (char **) &inbuf, &inleft, &outbuf, &outleft); + fprintf(stderr, "-> %ld %s %p %ld %ld\n", converted, inbuf, outbuf, inleft, outleft); // DEBUG if (converted != (size_t) -1 || errno == EINVAL) { /* finished or invalid multibyte, so truncate and ignore */ break; |