From 7c2ffc204a37e52375678b902999be4215d790a9 Mon Sep 17 00:00:00 2001 From: Martin Matuska Date: Sat, 3 Dec 2016 02:16:18 +0100 Subject: [PATCH] Fix hang in uudecode_filter_read() Reported-by: OSS-Fuzz issue 16 --- libarchive/archive_read_support_filter_uu.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libarchive/archive_read_support_filter_uu.c b/libarchive/archive_read_support_filter_uu.c index 1d682af29..1084c4154 100644 --- a/libarchive/archive_read_support_filter_uu.c +++ b/libarchive/archive_read_support_filter_uu.c @@ -511,6 +511,13 @@ read_more: } llen = len; if ((nl == 0) && (uudecode->state != ST_UUEND)) { + if (total == 0 && ravail <= 0) { + /* There is nothing more to read, fail */ + archive_set_error(&self->archive->archive, + ARCHIVE_ERRNO_FILE_FORMAT, + "Missing format data"); + return (ARCHIVE_FATAL); + } /* * Save remaining data which does not contain * NL('\n','\r'). -- 2.47.3