diff options
author | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2014-02-05 13:13:12 -0800 |
---|---|---|
committer | Evan Shelhamer <shelhamer@imaginarynumber.net> | 2014-02-05 13:13:12 -0800 |
commit | a039ff6486a3d802f670357516594fcff2e05be9 (patch) | |
tree | 3b0ad1e8fd5b5e09280e89a1e2efd73af6d216be /examples | |
parent | 08d31497bdb31e3caae16e84a00ab3af2a8f4d5f (diff) | |
parent | 5b4d91d76eac44b5b37b3d8088fda8b7f6204f15 (diff) | |
download | caffe-a039ff6486a3d802f670357516594fcff2e05be9.tar.gz caffe-a039ff6486a3d802f670357516594fcff2e05be9.tar.bz2 caffe-a039ff6486a3d802f670357516594fcff2e05be9.zip |
Merge pull request #70 from petewarden/buffer-overflow
Fix for buffer overflow problem with long filenames when setting up the LevelDB
Diffstat (limited to 'examples')
-rw-r--r-- | examples/convert_imageset.cpp | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/examples/convert_imageset.cpp b/examples/convert_imageset.cpp index 01c5f1ad..ee0e3adf 100644 --- a/examples/convert_imageset.cpp +++ b/examples/convert_imageset.cpp @@ -66,7 +66,8 @@ 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, @@ -74,7 +75,7 @@ int main(int argc, char** argv) { 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); |