We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent d767d79 commit 2253154Copy full SHA for 2253154
libarchive/archive_write.c
@@ -673,8 +673,13 @@ static ssize_t
673
_archive_write_data(struct archive *_a, const void *buff, size_t s)
674
{
675
struct archive_write *a = (struct archive_write *)_a;
676
+ const size_t max_write = INT_MAX;
677
+
678
archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC,
679
ARCHIVE_STATE_DATA, "archive_write_data");
680
+ /* In particular, this catches attempts to pass negative values. */
681
+ if (s > max_write)
682
+ s = max_write;
683
archive_clear_error(&a->archive);
684
return ((a->format_write_data)(a, buff, s));
685
}
0 commit comments