mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
Security fixes: #2364 tar: don't crash on truncated tar archives #2366 gzip: prevent a hang when processing a malformed gzip inside a gzip #2377 tar: fix two leaks in tar header parsing Important bugfixes: #2096 rar5: report encrypted entries #2252 7-zip: read/write symlink paths as UTF-8 #2360 tar: fix truncation of entry pathnames in specific archives Obtained from: libarchive Vendor commit: b439d586f53911c84be5e380445a8a259e19114c
57 lines
1.4 KiB
C
57 lines
1.4 KiB
C
/*-
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*
|
|
* Copyright (c) 2003-2007 Tim Kientzle
|
|
* All rights reserved.
|
|
*/
|
|
#include "test.h"
|
|
|
|
/*
|
|
* Test that "--help", "-h", and "-W help" options all work and
|
|
* generate reasonable output.
|
|
*/
|
|
|
|
static int
|
|
in_first_line(const char *p, const char *substring)
|
|
{
|
|
size_t l = strlen(substring);
|
|
|
|
while (*p != '\0' && *p != '\n') {
|
|
if (memcmp(p, substring, l) == 0)
|
|
return (1);
|
|
++p;
|
|
}
|
|
return (0);
|
|
}
|
|
|
|
DEFINE_TEST(test_help)
|
|
{
|
|
int r;
|
|
char *p;
|
|
size_t plen;
|
|
|
|
/* Exercise --help option. */
|
|
r = systemf("%s --help >help.stdout 2>help.stderr", testprog);
|
|
assertEqualInt(r, 0);
|
|
failure("--help should generate nothing to stderr.");
|
|
assertEmptyFile("help.stderr");
|
|
/* Help message should start with name of program. */
|
|
p = slurpfile(&plen, "help.stdout");
|
|
failure("Help output should be long enough.");
|
|
assert(plen >= 6);
|
|
failure("First line of help output should contain 'bsdcat': %s", p);
|
|
assert(in_first_line(p, "bsdcat"));
|
|
/*
|
|
* TODO: Extend this check to further verify that --help output
|
|
* looks approximately right.
|
|
*/
|
|
free(p);
|
|
|
|
/* -h option should generate the same output. */
|
|
r = systemf("%s -h >h.stdout 2>h.stderr", testprog);
|
|
assertEqualInt(r, 0);
|
|
failure("-h should generate nothing to stderr.");
|
|
assertEmptyFile("h.stderr");
|
|
failure("stdout should be same for -h and --help");
|
|
assertEqualFile("h.stdout", "help.stdout");
|
|
}
|