Check for errors in a2d_ASN1_OBJECT()
[oweals/openssl.git] / crypto / asn1 / a_object.c
index fba9f66454df2dcd9ff16349ec9fce862a118349..229a40ffa34447fd23265c65fc168f91480319b3 100644 (file)
@@ -174,8 +174,12 @@ int a2d_ASN1_OBJECT(unsigned char *out, int olen, const char *buf, int num)
                 if (!tmp)
                     goto err;
             }
-            while (blsize--)
-                tmp[i++] = (unsigned char)BN_div_word(bl, 0x80L);
+            while (blsize--) {
+                BN_ULONG t = BN_div_word(bl, 0x80L);
+                if (t == (BN_ULONG)-1)
+                    goto err;
+                tmp[i++] = (unsigned char)t;
+            }
         } else {
 
             for (;;) {