Add crude file size check to do_server_checksum_listing()

This commit is contained in:
Scott Lystig Fritchie 2015-06-30 14:13:26 +09:00
parent 2d070bf1e3
commit 310fdb1f6a

View file

@ -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, _} ->