diff options
author | mm <mm@FreeBSD.org> | 2013-03-22 13:36:03 +0000 |
---|---|---|
committer | mm <mm@FreeBSD.org> | 2013-03-22 13:36:03 +0000 |
commit | 5ee0a7b76c4addc27bb45864cb4e0ce790a4b80e (patch) | |
tree | e741e3532b574e7c25aa9bb07c18cdb16139824f /contrib/libarchive/tar/util.c | |
parent | af89cb16bfde2fc8e93708b89daff55026d3b216 (diff) | |
parent | 366f42737cba40ceb2e83af8d17c61c0242703c5 (diff) | |
download | FreeBSD-src-5ee0a7b76c4addc27bb45864cb4e0ce790a4b80e.zip FreeBSD-src-5ee0a7b76c4addc27bb45864cb4e0ce790a4b80e.tar.gz |
MFV r248590,248594:
Update libarchive to 3.1.2
Some of new features:
- support for lrzip and grzip compression
- support for writing tar v7 format
- b64encode and uuencode filters
- support for __MACOSX directory in Zip archives
- support for lzop compresion (external utility)
Diffstat (limited to 'contrib/libarchive/tar/util.c')
-rw-r--r-- | contrib/libarchive/tar/util.c | 24 |
1 files changed, 13 insertions, 11 deletions
diff --git a/contrib/libarchive/tar/util.c b/contrib/libarchive/tar/util.c index 6112840..a6f3189 100644 --- a/contrib/libarchive/tar/util.c +++ b/contrib/libarchive/tar/util.c @@ -120,14 +120,12 @@ safe_fprintf(FILE *f, const char *fmt, ...) fmtbuff_length = length+1; else if (fmtbuff_length < 8192) fmtbuff_length *= 2; - else { - int old_length = fmtbuff_length; + else if (fmtbuff_length < 1000000) fmtbuff_length += fmtbuff_length / 4; - if (old_length > fmtbuff_length) { - length = old_length; - fmtbuff_heap[length-1] = '\0'; - break; - } + else { + length = fmtbuff_length; + fmtbuff_heap[length-1] = '\0'; + break; } free(fmtbuff_heap); fmtbuff_heap = malloc(fmtbuff_length); @@ -148,7 +146,12 @@ safe_fprintf(FILE *f, const char *fmt, ...) /* Note: mbrtowc() has a cleaner API, but mbtowc() seems a bit * more portable, so we use that here instead. */ - n = mbtowc(NULL, NULL, 1); /* Reset the shift state. */ + if (mbtowc(NULL, NULL, 1) == -1) { /* Reset the shift state. */ + /* mbtowc() should never fail in practice, but + * handle the theoretical error anyway. */ + free(fmtbuff_heap); + return; + } /* Write data, expanding unprintable characters. */ p = fmtbuff; @@ -188,8 +191,7 @@ safe_fprintf(FILE *f, const char *fmt, ...) fprintf(f, "%s", outbuff); /* If we allocated a heap-based formatting buffer, free it now. */ - if (fmtbuff_heap != NULL) - free(fmtbuff_heap); + free(fmtbuff_heap); } /* @@ -380,7 +382,7 @@ int edit_pathname(struct bsdtar *bsdtar, struct archive_entry *entry) { const char *name = archive_entry_pathname(entry); -#if HAVE_REGEX_H +#if defined(HAVE_REGEX_H) || defined(HAVE_PCREPOSIX_H) char *subst_name; int r; |