From 310fdb1f6a3215437b4be3da3f049a0ddfb28879 Mon Sep 17 00:00:00 2001 From: Scott Lystig Fritchie Date: Tue, 30 Jun 2015 14:13:26 +0900 Subject: [PATCH] Add crude file size check to do_server_checksum_listing() --- src/machi_flu1.erl | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/machi_flu1.erl b/src/machi_flu1.erl index 033d4a1..997eb35 100644 --- a/src/machi_flu1.erl +++ b/src/machi_flu1.erl @@ -561,7 +561,16 @@ do_server_checksum_listing(File, #state{data_dir=DataDir}=_S) -> %% {packet_size,N} limit, then we'll have a difficult time, eh? case file:read_file(CSumPath) of {ok, Bin} -> - {ok, Bin}; + if byte_size(Bin) > (?PB_MAX_MSG_SIZE - 1024) -> + %% TODO: Fix this limitation by streaming the + %% binary in multiple smaller PB messages. + %% Also, don't read the file all at once. ^_^ + error_logger:error_msg("~s:~w oversize ~s\n", + [?MODULE, ?LINE, CSumPath]), + {error, bad_arg}; + true -> + {ok, Bin} + end; {error, enoent} -> {error, no_such_file}; {error, _} ->