https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123374
--- Comment #13 from Siddhesh Poyarekar <siddhesh at gcc dot gnu.org> ---
Took all of 24 hours to reduce and generated 4 cvise bug reports in the
process, but here it is:
typedef struct {
unsigned header_size;
} lzma_block;
long __read_alias(int, void *, unsigned long)
__attribute__((__access__(__write_only__, 2, 3)));
int read___fd;
long read(void *__buf, long __nbytes) {
long __trans_tmp_1 = __builtin_dynamic_object_size(__buf, 0);
return __builtin_constant_p(__trans_tmp_1) &&
__trans_tmp_1 == (long)-1
? __read_alias(read___fd, __buf, __nbytes)
: 0;
}
struct defer_dtor {
defer_dtor(lzma_block *, void(lzma_block *));
};
void free_lzma_block_filters(lzma_block *);
char extract_xz_blocks_into_fd_in_buf[4096];
long extract_xz_blocks_into_fd_bytes_read;
void extract_xz_blocks_into_fd() {
lzma_block block;
defer_dtor(&block, free_lzma_block_filters);
unsigned long header_read = 0;
while (header_read == 0)
header_read += extract_xz_blocks_into_fd_bytes_read;
while (header_read < block.header_size) {
long bytes_read =
read(extract_xz_blocks_into_fd_in_buf + header_read,
sizeof(extract_xz_blocks_into_fd_in_buf) - header_read);
if (bytes_read)
continue;
header_read += bytes_read;
}
}