Fix warning in Coverity.
The warning was caused by the use of strcmp with a string returned by readlink, which doesn't guarantee that the string is null-terminated. In this case the use of strcmp is not required as we are checking only one character.
@@ -40,9 +40,9 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#else
-#include <windows.h>
#include <fcntl.h>
#include <io.h>
+#include <windows.h>
#define PRIx64 "I64x"
#define PRId64 "I64d"
@@ -405,7 +405,6 @@ static int file_queue_put(const char_t* file_path, time_t deadline)
return ERROR_SUCCESS;
}
-
static char_t* file_queue_get(time_t deadline)
{
char_t* result;
@@ -444,7 +443,6 @@ static bool is_directory(const char_t* path)
return false;
}
-
static int scan_dir(const char_t* dir, SCAN_OPTIONS* scan_opts)
{
int result = ERROR_SUCCESS;
@@ -632,10 +630,9 @@ static int scan_dir(const char* dir, SCAN_OPTIONS* scan_opts)
else if (S_ISLNK(st.st_mode))
{
char buf[2];
-
int len = readlink(full_path, buf, sizeof(buf));
- if (len == 1 && strcmp(buf, ".") == 0)
+ if (len == 1 && buf[0] == '.')
{
de = readdir(dp);
continue;
@@ -667,7 +664,6 @@ static int scan_dir(const char* dir, SCAN_OPTIONS* scan_opts)
return result;
}
-
static int scan_file(YR_SCANNER* scanner, const char_t* filename)
{
YR_FILE_DESCRIPTOR fd = open(filename, O_RDONLY);
@@ -682,7 +678,6 @@ static int scan_file(YR_SCANNER* scanner, const char_t* filename)
return result;
}
-
static int populate_scan_list(const char* filename, SCAN_OPTIONS* scan_opts)
{
size_t nsize = 0;
@@ -1136,8 +1131,8 @@ static int callback(
cli_mutex_lock(&output_mutex);
#if defined(_WIN32)
- // In Windows restore stdout to normal text mode as yr_object_print_data calls
- // printf which is not supported in UTF-8 mode.
+ // In Windows restore stdout to normal text mode as yr_object_print_data
+ // calls printf which is not supported in UTF-8 mode.
_setmode(_fileno(stdout), _O_TEXT);
#endif
@@ -1283,7 +1278,6 @@ static void unload_modules_data()
modules_data_list = NULL;
}
-
int _tmain(int argc, const char_t** argv)
{
COMPILER_RESULTS cr;
