pax_global_header00006660000000000000000000000064134171720270014516gustar00rootroot0000000000000052 comment=7d794092a5e937118c6fc3123a5f662c29a6dae8 lz4json-2/000077500000000000000000000000001341717202700126245ustar00rootroot00000000000000lz4json-2/Makefile000066400000000000000000000002001341717202700142540ustar00rootroot00000000000000CFLAGS := -g -O2 -Wall LDLIBS := $(shell pkg-config --cflags --libs liblz4) lz4jsoncat: lz4jsoncat.c clean: rm -f lz4jsoncat lz4json-2/README000066400000000000000000000006271341717202700135110ustar00rootroot00000000000000A little utility to unpack lz4json files as generated by Firefox's bookmark backups and session restore. This is a different format from what the normal lz4 utility expects. The data is dumped to stdout. Requires liblz4 (Debian package liblz4-dev, Fedora package lz4-devel) to be installed. lz4jsoncat ~/.mozilla/.../bookmarkbackups/bookmarks-2014-12-27_151_0UCIWGB4x3hhQXpuSMs5WQ==.jsonlz4 -Andi Kleen lz4json-2/lz4jsoncat.1000066400000000000000000000006031341717202700150000ustar00rootroot00000000000000.TH lz4jsoncat 1 2018-12-25 .SH NAME lz4jsoncat \- decompress tool for mozilla lz4json format .SH SYNOPSIS .B lz4jsoncat .I somefile.mozlz4 > .I somefile.json .SH DESCRIPTION .B lz4jsoncat can unpack lz4json files as generated by Firefox's bookmark backups and session restore. The data is dumped to stdout. .SH CAVEATS The input file must be mmappable \- so you can't use a pipe here. lz4json-2/lz4jsoncat.c000066400000000000000000000041201341717202700150600ustar00rootroot00000000000000/* * Dump mozilla style lz4json files. * * Copyright (c) 2014 Intel Corporation * Author: Andi Kleen * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that: (1) source code distributions * retain the above copyright notice and this paragraph in its entirety, (2) * distributions including binary code include the above copyright notice and * this paragraph in its entirety in the documentation or other materials * provided with the distribution * * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ /* File format reference: https://dxr.mozilla.org/mozilla-central/source/toolkit/components/lz4/lz4.js */ #include #include #include #include #include #include #include #include #include #include #include "lz4.h" int main(int ac, char **av) { while (*++av) { int fd = open(*av, O_RDONLY); if (fd < 0) { perror(*av); continue; } struct stat st; if (fstat(fd, &st) < 0) { perror(*av); exit(1); } if (st.st_size < 12) { fprintf(stderr, "%s: file too short\n", *av); exit(1); } char *map = mmap(NULL, st.st_size, PROT_READ, MAP_SHARED, fd, 0); if (map == (char *)-1) { perror(*av); exit(1); } if (memcmp(map, "mozLz40", 8)) { fprintf(stderr, "%s: not a mozLZ4a file\n", *av); exit(1); } size_t outsz = htole32(*(uint32_t *) (map + 8)); char *out = malloc(outsz); if (!out) { fprintf(stderr, "Cannot allocate memory\n"); exit(1); } if (LZ4_decompress_safe_partial(map + 12, out, st.st_size - 12, outsz, outsz) < 0) { fprintf(stderr, "%s: decompression error\n", *av); exit(1); } ssize_t decsz = write(1, out, outsz); if (decsz < 0 || decsz != outsz) { if (decsz >= 0) errno = EIO; perror("write"); exit(1); } free(out); munmap(map, st.st_size); close(fd); } return 0; }