1
0
Files
kernel-49/tools/perf/util/lzma.c
Greg Kroah-Hartman 6d72db0b2f Merge 4.9.277 into android-4.9-q
Changes in 4.9.277
	ARM: dts: rockchip: fix pinctrl sleep nodename for rk3036-kylin and rk3288
	ARM: dts: rockchip: Fix power-controller node names for rk3288
	reset: ti-syscon: fix to_ti_syscon_reset_data macro
	ARM: brcmstb: dts: fix NAND nodes names
	ARM: dts: BCM63xx: Fix NAND nodes names
	ARM: dts: imx6: phyFLEX: Fix UART hardware flow control
	ARM: imx: pm-imx5: Fix references to imx5_cpu_suspend_info
	ARM: dts: stm32: fix RCC node name on stm32f429 MCU
	arm64: dts: juno: Update SCPI nodes as per the YAML schema
	thermal/core: Correct function name thermal_zone_device_unregister()
	kbuild: mkcompile_h: consider timestamp if KBUILD_BUILD_TIMESTAMP is set
	rtc: max77686: Do not enforce (incorrect) interrupt trigger type
	scsi: aic7xxx: Fix unintentional sign extension issue on left shift of u8
	sched/fair: Fix CFS bandwidth hrtimer expiry type
	net: ipv6: fix return value of ip6_skb_dst_mtu
	net: bridge: sync fdb to new unicast-filtering ports
	net: bcmgenet: Ensure all TX/RX queues DMAs are disabled
	net: moxa: fix UAF in moxart_mac_probe
	net: qcom/emac: fix UAF in emac_remove
	net: ti: fix UAF in tlan_remove_one
	net: validate lwtstate->data before returning from skb_tunnel_info()
	tcp: annotate data races around tp->mtu_info
	ipv6: tcp: drop silly ICMPv6 packet too big messages
	ixgbe: Fix an error handling path in 'ixgbe_probe()'
	igb: Fix an error handling path in 'igb_probe()'
	fm10k: Fix an error handling path in 'fm10k_probe()'
	e1000e: Fix an error handling path in 'e1000_probe()'
	iavf: Fix an error handling path in 'iavf_probe()'
	igb: Check if num of q_vectors is smaller than max before array access
	perf lzma: Close lzma stream on exit
	perf test bpf: Free obj_buf
	perf probe-file: Delete namelist in del_events() on the error path
	spi: mediatek: fix fifo rx mode
	s390/bpf: Perform r1 range checking before accessing jit->seen_reg[r1]
	net: fix uninit-value in caif_seqpkt_sendmsg
	net: decnet: Fix sleeping inside in af_decnet
	netrom: Decrease sock refcount when sock timers expire
	scsi: iscsi: Fix iface sysfs attr detection
	scsi: target: Fix protect handling in WRITE SAME(32)
	Revert "USB: quirks: ignore remote wake-up on Fibocom L850-GL LTE modem"
	proc: Avoid mixing integer types in mem_rw()
	Revert "MIPS: add PMD table accounting into MIPS'pmd_alloc_one"
	s390/ftrace: fix ftrace_update_ftrace_func implementation
	ALSA: sb: Fix potential ABBA deadlock in CSP driver
	xhci: Fix lost USB 2 remote wake
	KVM: PPC: Book3S: Fix H_RTAS rets buffer overflow
	usb: hub: Disable USB 3 device initiated lpm if exit latency is too high
	USB: usb-storage: Add LaCie Rugged USB3-FW to IGNORE_UAS
	usb: max-3421: Prevent corruption of freed memory
	usb: renesas_usbhs: Fix superfluous irqs happen after usb_pkt_pop()
	USB: serial: option: add support for u-blox LARA-R6 family
	USB: serial: cp210x: fix comments for GE CS1000
	USB: serial: cp210x: add ID for CEL EM3588 USB ZigBee stick
	tracing: Fix bug in rb_per_cpu_empty() that might cause deadloop.
	media: ngene: Fix out-of-bounds bug in ngene_command_config_free_buf()
	net: bcmgenet: ensure EXT_ENERGY_DET_MASK is clear
	iio: accel: bma180: Use explicit member assignment
	iio: accel: bma180: Fix BMA25x bandwidth register values
	btrfs: compression: don't try to compress if we don't have enough pages
	Linux 4.9.277

Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
Change-Id: Ibb9aa2b6a757b06f50f0e77ef193df58dc813646
2021-07-29 23:33:07 +03:00

101 lines
2.1 KiB
C

#include <lzma.h>
#include <stdio.h>
#include <linux/compiler.h>
#include "util.h"
#include "debug.h"
#define BUFSIZE 8192
static const char *lzma_strerror(lzma_ret ret)
{
switch ((int) ret) {
case LZMA_MEM_ERROR:
return "Memory allocation failed";
case LZMA_OPTIONS_ERROR:
return "Unsupported decompressor flags";
case LZMA_FORMAT_ERROR:
return "The input is not in the .xz format";
case LZMA_DATA_ERROR:
return "Compressed file is corrupt";
case LZMA_BUF_ERROR:
return "Compressed file is truncated or otherwise corrupt";
default:
return "Unknown error, possibly a bug";
}
}
int lzma_decompress_to_file(const char *input, int output_fd)
{
lzma_action action = LZMA_RUN;
lzma_stream strm = LZMA_STREAM_INIT;
lzma_ret ret;
int err = -1;
u8 buf_in[BUFSIZE];
u8 buf_out[BUFSIZE];
FILE *infile;
infile = fopen(input, "rb");
if (!infile) {
pr_err("lzma: fopen failed on %s: '%s'\n",
input, strerror(errno));
return -1;
}
ret = lzma_stream_decoder(&strm, UINT64_MAX, LZMA_CONCATENATED);
if (ret != LZMA_OK) {
pr_err("lzma: lzma_stream_decoder failed %s (%d)\n",
lzma_strerror(ret), ret);
goto err_fclose;
}
strm.next_in = NULL;
strm.avail_in = 0;
strm.next_out = buf_out;
strm.avail_out = sizeof(buf_out);
while (1) {
if (strm.avail_in == 0 && !feof(infile)) {
strm.next_in = buf_in;
strm.avail_in = fread(buf_in, 1, sizeof(buf_in), infile);
if (ferror(infile)) {
pr_err("lzma: read error: %s\n", strerror(errno));
goto err_lzma_end;
}
if (feof(infile))
action = LZMA_FINISH;
}
ret = lzma_code(&strm, action);
if (strm.avail_out == 0 || ret == LZMA_STREAM_END) {
ssize_t write_size = sizeof(buf_out) - strm.avail_out;
if (writen(output_fd, buf_out, write_size) != write_size) {
pr_err("lzma: write error: %s\n", strerror(errno));
goto err_lzma_end;
}
strm.next_out = buf_out;
strm.avail_out = sizeof(buf_out);
}
if (ret != LZMA_OK) {
if (ret == LZMA_STREAM_END)
break;
pr_err("lzma: failed %s\n", lzma_strerror(ret));
goto err_lzma_end;
}
}
err = 0;
err_lzma_end:
lzma_end(&strm);
err_fclose:
fclose(infile);
return err;
}