1
0
Эх сурвалжийг харах

Update hfile.h (#236)

如果filepath超过260字节,可能导致this->filepath不是以'\0'结尾
MrSen 3 жил өмнө
parent
commit
e7e878deb0
1 өөрчлөгдсөн 1 нэмэгдсэн , 1 устгасан
  1. 1 1
      cpputil/hfile.h

+ 1 - 1
cpputil/hfile.h

@@ -18,7 +18,7 @@ public:
 
     int open(const char* filepath, const char* mode) {
         close();
-        strncpy(this->filepath, filepath, MAX_PATH);
+        strncpy(this->filepath, filepath, MAX_PATH - 1);
         fp = fopen(filepath, mode);
         return fp ? 0 : errno;
     }