Skip to content

Commit d3de067

Browse files
committed
Restricting length of names of serialised files to max. allowed size.
1 parent b097c8f commit d3de067

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/util/json_map_serializer.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,12 @@ class json_map_serializert:public virtual_map_iterated_by_keyt<keyt, valuet>
254254
path=get_existing_path(key);
255255
else
256256
{
257-
std::string file_name=make_valid_filename(key_converter(key));
257+
const std::size_t max_size =
258+
MAX_FILE_NAME_SIZE // The general size limit.
259+
- 15 // Save space for unique ID integer.
260+
- std::string(suffix).size(); // Save space for '.json' extension
261+
std::string file_name =
262+
make_valid_filename(key_converter(key), max_size);
258263
unsigned long uniqueness=file_name==index_file_name ? 1 : 0;
259264
while(index.right.count(uniqueify(file_name, uniqueness)) != 0)
260265
++uniqueness;

0 commit comments

Comments
 (0)