Skip to content

Commit

Permalink
Fix for buffer overflow problem with long filenames when setting up t…
Browse files Browse the repository at this point in the history
…he LevelDB
  • Loading branch information
jetpaccomputer committed Feb 5, 2014
1 parent 1fcf37b commit 5b4d91d
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions examples/convert_imageset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,16 @@ int main(int argc, char** argv) {
string root_folder(argv[1]);
Datum datum;
int count = 0;
char key_cstr[100];
const int maxKeyLength = 256;
char key_cstr[maxKeyLength];
leveldb::WriteBatch* batch = new leveldb::WriteBatch();
for (int line_id = 0; line_id < lines.size(); ++line_id) {
if (!ReadImageToDatum(root_folder + lines[line_id].first, lines[line_id].second,
&datum)) {
continue;
};
// sequential
sprintf(key_cstr, "%08d_%s", line_id, lines[line_id].first.c_str());
snprintf(key_cstr, maxKeyLength, "%08d_%s", line_id, lines[line_id].first.c_str());
string value;
// get the value
datum.SerializeToString(&value);
Expand Down

0 comments on commit 5b4d91d

Please sign in to comment.