Ver Fonte

Fix overflow in aiString

Kim Kulling há 4 anos atrás
pai
commit
5a764fff04
1 ficheiros alterados com 5 adições e 2 exclusões
  1. 5 2
      include/assimp/types.h

+ 5 - 2
include/assimp/types.h

@@ -307,7 +307,7 @@ struct aiString {
     void Set(const char *sz) {
     void Set(const char *sz) {
         const ai_int32 len = (ai_uint32)::strlen(sz);
         const ai_int32 len = (ai_uint32)::strlen(sz);
         if (len > (ai_int32)MAXLEN - 1) {
         if (len > (ai_int32)MAXLEN - 1) {
-            return;
+            len = (ai_int32) MAXLEN - 1;
         }
         }
         length = len;
         length = len;
         memcpy(data, sz, len);
         memcpy(data, sz, len);
@@ -321,7 +321,10 @@ struct aiString {
         }
         }
 
 
         length = rOther.length;
         length = rOther.length;
-        ;
+        if (length >(MAXLEN - 1)) {
+            length = (ai_int32) MAXLEN - 1;
+        }
+
         memcpy(data, rOther.data, length);
         memcpy(data, rOther.data, length);
         data[length] = '\0';
         data[length] = '\0';
         return *this;
         return *this;