Imported Upstream version 1.3.4
[platform/upstream/libksba.git] / src / dn.c
index d207bf0..cea18a1 100644 (file)
--- a/src/dn.c
+++ b/src/dn.c
@@ -332,11 +332,8 @@ append_utf8_value (const unsigned char *value, size_t length,
         }
       else
         {
-          if (n+nmore > length)
-            nmore = length - n; /* Oops, encoding to short */
-
           tmp[0] = *s++; n++;
-          for (i=1; i <= nmore; i++)
+          for (i=1; n < length && i <= nmore; i++)
             {
               if ( (*s & 0xc0) != 0x80)
                 break; /* Invalid encoding - let the next cycle detect this. */