Skip to content

Commit 964b5cc

Browse files
mingodada4lg
authored andcommitted
There was a cmpiler warning about string truncation because the format string size was not taken into account.
1 parent d2eaa97 commit 964b5cc

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

engine.cpp

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// $Id$
1+
// $Id$
22

33
#include "main.h"
44
#include "ssdeep.h"
@@ -13,7 +13,7 @@ bool display_result(state *s, const TCHAR * fn, const char * sum) {
1313

1414
try {
1515
f = new Filedata(fn, sum);
16-
}
16+
}
1717
catch (std::bad_alloc) {
1818
fatal_error("%s: Unable to create Filedata object in engine.cpp:display_result()", __progname);
1919
}
@@ -61,12 +61,12 @@ int hash_file(state *s, TCHAR *fn) {
6161
TCHAR *my_filename, *msg;
6262
FILE *handle;
6363

64-
#ifdef WIN32
64+
#ifdef WIN32
6565
TCHAR expanded_fn[SSDEEP_PATH_MAX];
6666
if (not expanded_path(fn) && !(s->mode & mode_relative)) {
67-
_sntprintf(expanded_fn,
67+
_sntprintf(expanded_fn,
6868
SSDEEP_PATH_MAX,
69-
_TEXT("\\\\?\\%s"),
69+
_TEXT("\\\\?\\%s"),
7070
fn);
7171
} else {
7272
_tcsncpy(expanded_fn, fn, SSDEEP_PATH_MAX);
@@ -89,7 +89,8 @@ int hash_file(state *s, TCHAR *fn) {
8989
return TRUE;
9090
}
9191

92-
if ((msg = (TCHAR *)malloc(sizeof(TCHAR) * (MAX_STATUS_MSG + 2))) == NULL)
92+
#define MSG_LENGTH (MAX_STATUS_MSG + 20)
93+
if ((msg = (TCHAR *)malloc(sizeof(TCHAR) * MSG_LENGTH)) == NULL)
9394
{
9495
free(sum);
9596
fclose(handle);
@@ -111,9 +112,9 @@ int hash_file(state *s, TCHAR *fn) {
111112
my_filename = fn;
112113

113114
_sntprintf(msg,
114-
MAX_STATUS_MSG-1,
115-
_TEXT("Hashing: %s%s"),
116-
my_filename,
115+
MSG_LENGTH-1,
116+
_TEXT("Hashing: %s%s"),
117+
my_filename,
117118
_TEXT(BLANK_LINE));
118119
_ftprintf(stderr,_TEXT("%s\r"), msg);
119120

0 commit comments

Comments
 (0)