Explorar o código

Update hfile.h (#236)

如果filepath超过260字节,可能导致this->filepath不是以'\0'结尾
MrSen %!s(int64=3) %!d(string=hai) anos
pai
achega
e7e878deb0
Modificáronse 1 ficheiros con 1 adicións e 1 borrados
  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;
     }