!3085 init安全问题修复

Merge pull request !3085 from zl郑磊/master_0819
This commit is contained in:
openharmony_ci 2024-08-23 06:29:16 +00:00 committed by Gitee
commit 415968c693
No known key found for this signature in database
GPG Key ID: 173E9B9CA92EEF8F

View File

@ -191,7 +191,7 @@ char *ReadFileData(const char *fileName)
INIT_ERROR_CHECK(buffer != NULL, close(fd);
return NULL, "Failed to allocate memory for %s", fileName);
ssize_t readLen = read(fd, buffer, MAX_SMALL_BUFFER - 1);
INIT_ERROR_CHECK((readLen > 0) && (readLen < (MAX_SMALL_BUFFER - 1)), close(fd);
INIT_ERROR_CHECK((readLen > 0) && (readLen <= (MAX_SMALL_BUFFER - 1)), close(fd);
free(buffer);
return NULL, "Failed to read data for %s", fileName);
buffer[readLen] = '\0';