Skip to content

Commit 2f0229a

Browse files
committed
Fix underflow vulnerability
When file size is zero while decrypting, the subtraction of offset of HASH size results in underflow. Return is_ok = false in such cases. Signed-off-by: Shashank Verma <shashank.verma2002@gmail.com>
1 parent fc7ea43 commit 2f0229a

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cli.hpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,8 +329,16 @@ namespace cli {
329329
is_open = false;
330330
return;
331331
}
332-
mode = xrc_mode;
332+
mode = xrc_mode;
333+
333334
byte64 file_length = std::filesystem::file_size(src_path);
335+
if (file_length == 0) {
336+
f_src_file.close();
337+
f_out_file.close();
338+
is_open = false;
339+
std::filesystem::remove(src_path);
340+
return;
341+
}
334342
if (mode == XorCryptor::Mode::DECRYPT) file_length -= 32ULL;
335343

336344
buffer_manager = new BufferManager(file_length);

0 commit comments

Comments
 (0)