# | Line 671 | Line 671 | static ssize_t | |
---|---|---|
671 | _archive_write_data(struct archive *_a, const void *buff, size_t s) | |
672 | { | |
673 | struct archive_write *a = (struct archive_write *)_a; | |
674 | + | const size_t max_write = INT_MAX; |
675 | + | |
676 | archive_check_magic(&a->archive, ARCHIVE_WRITE_MAGIC, | |
677 | ARCHIVE_STATE_DATA, "archive_write_data"); | |
678 | + | /* In particular, this catches attempts to pass negative values. */ |
679 | + | if (s > max_write) |
680 | + | s = max_write; |
681 | archive_clear_error(&a->archive); | |
682 | return ((a->format_write_data)(a, buff, s)); | |
683 | } |
– | Removed lines |
+ | Added lines |
< | Changed lines |
> | Changed lines |