diff --git a/lrzip.c b/lrzip.c index 43fa050..baa26eb 100644 --- a/lrzip.c +++ b/lrzip.c @@ -34,6 +34,7 @@ #ifdef HAVE_ERRNO_H #include #endif +#include #include #include @@ -357,7 +358,7 @@ int open_tmpinfile(rzip_control *control) static void read_tmpinmagic(rzip_control *control) { char magic[MAGIC_LEN]; - int md5, i, tmpchar; + int i, tmpchar; memset(magic, 0, sizeof(magic)); for (i = 0; i < 24; i++) { @@ -946,7 +947,7 @@ void compress_file(rzip_control *control) const char *tmp, *tmpinfile; /* we're just using this as a proxy for control->infile. * Spares a compiler warning */ - int fd_in, fd_out; + int fd_in, fd_out = -1; char header[MAGIC_LEN]; if (ENCRYPT) diff --git a/lrzip.h b/lrzip.h index b59c351..b519396 100644 --- a/lrzip.h +++ b/lrzip.h @@ -33,6 +33,7 @@ void get_header_info(rzip_control *control, int fd_in, uchar *ctype, i64 *c_len, void get_fileinfo(rzip_control *control); void compress_file(rzip_control *control); void write_fdout(rzip_control *control, void *buf, i64 len); +void write_fdin(struct rzip_control *control); void flush_tmpoutbuf(rzip_control *control); void close_tmpoutbuf(rzip_control *control); void clear_tmpinbuf(rzip_control *control); diff --git a/main.c b/main.c index f3d0e37..3b97d6b 100644 --- a/main.c +++ b/main.c @@ -136,7 +136,6 @@ static inline i64 get_ram(void) i64 ramsize; FILE *meminfo; char aux[256]; - char *ignore; ramsize = (i64)sysconf(_SC_PHYS_PAGES) * PAGE_SIZE; if (ramsize > 0) @@ -146,8 +145,10 @@ static inline i64 get_ram(void) if(!(meminfo = fopen("/proc/meminfo", "r"))) fatal("fopen\n"); - while(!feof(meminfo) && !fscanf(meminfo, "MemTotal: %Lu kB", &ramsize)) - ignore = fgets(aux, sizeof(aux), meminfo); + while(!feof(meminfo) && !fscanf(meminfo, "MemTotal: %Lu kB", &ramsize)) { + if (unlikely(fgets(aux, sizeof(aux), meminfo) == NULL)) + fatal("Failed to fgets in get_ram\n"); + } if (fclose(meminfo) == -1) fatal("fclose"); ramsize *= 1000; @@ -767,7 +768,7 @@ int main(int argc, char *argv[]) * used in alloc */ usable_ram = MAX(control.ramsize - 900000000ll, 900000000ll); control.maxram = MIN(control.maxram, usable_ram); - control.maxram = MIN(control.maxram, two_gig); + control.maxram = MIN((unsigned long long)control.maxram, two_gig); } round_to_page(&control.maxram); diff --git a/rzip.c b/rzip.c index 088947f..6a3acfc 100644 --- a/rzip.c +++ b/rzip.c @@ -47,6 +47,7 @@ #include "stream.h" #include "util.h" #include "liblrzip.h" +#include "lrzip.h" /* needed for CRC routines */ #include "lzma/C/7zCrc.h" diff --git a/stream.c b/stream.c index b351b40..cf4bbd7 100644 --- a/stream.c +++ b/stream.c @@ -45,6 +45,7 @@ #include "util.h" #include "zpipe.h" #include "liblrzip.h" +#include "lrzip.h" #ifdef __APPLE__ @@ -1391,7 +1392,7 @@ static int fill_buffer(rzip_control *control, struct stream_info *sinfo, int str struct stream *s = &sinfo->s[streamno]; stream_thread_struct *st; uchar c_type, *s_buf; - uchar salt[16]; + uchar salt[BLOCKSALT_LEN]; if (s->buf) free(s->buf); diff --git a/stream.h b/stream.h index 3ba8c55..09d3b26 100644 --- a/stream.h +++ b/stream.h @@ -37,6 +37,7 @@ int write_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 le i64 read_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len); int close_stream_out(rzip_control *control, void *ss); int close_stream_in(void *ss); +ssize_t put_fdout(rzip_control *control, void *offset_buf, ssize_t ret); const i64 one_g; #endif