diff -ru a/crossapi.cpp b/crossapi.cpp --- a/crossapi.cpp 2022-09-13 21:20:00.721163933 +0300 +++ b/crossapi.cpp 2022-09-13 21:21:12.864326051 +0300 @@ -207,7 +207,8 @@ fprintf(stderr, "Can't stat file \"%s\": %s\n", szFileName, strerror_r(e, buff, sizeof(buff))); return -1; } - strncpy(cfd->cFileName,szFileName,CROSSAPI_MAX_PATH); + strncpy(cfd->cFileName,szFileName,sizeof(cfd->cFileName) - 1); + cfd->cFileName[sizeof(cfd->cFileName) - 1] = 0; if(inode.st_mode&S_IFDIR) cfd->bIsDirectory=true; else cfd->bIsDirectory=false; return 1; diff -ru a/crossapi.h b/crossapi.h --- a/crossapi.h 2009-06-26 00:14:07.000000000 +0400 +++ b/crossapi.h 2022-09-13 21:20:36.184243623 +0300 @@ -54,7 +54,7 @@ #endif struct CROSSAPI_FIND_DATA { - char cFileName[CROSSAPI_MAX_PATH]; + char cFileName[CROSSAPI_MAX_PATH+1]; bool bIsDirectory; };