From 42e3faba21cca76127a987d65e1c195b4b054a17 Mon Sep 17 00:00:00 2001 From: "cantab.net!aia21" Date: Thu, 26 Feb 2004 12:08:23 +0000 Subject: [PATCH] Fix the fix. (-: (Logical change 1.284) --- ntfsprogs/mkntfs.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/ntfsprogs/mkntfs.c b/ntfsprogs/mkntfs.c index 82e837e8..7205821b 100644 --- a/ntfsprogs/mkntfs.c +++ b/ntfsprogs/mkntfs.c @@ -567,12 +567,20 @@ int ucstos(char *dest, const uchar_t *src, int maxlen) * * Return the number of characters written to @dest, not including the * terminating null unicode character. + * + * If @maxlen is less than the size of a single unicode character we cannot + * write the terminating null unicode character and hence return -1 with errno + * set to EINVAL. */ int stoucs(uchar_t *dest, const char *src, int maxlen) { char c; int i; + if (maxlen < sizeof(uchar_t)) { + errno = EINVAL; + return -1; + } /* Convert maxlen from bytes to unicode characters. */ maxlen /= sizeof(uchar_t); /* Need space for null terminator. */