project
stringclasses 633
values | commit_id
stringlengths 7
81
| target
int64 0
1
| func
stringlengths 5
484k
| cwe
stringclasses 131
values | big_vul_idx
float64 0
189k
⌀ | idx
int64 0
522k
| hash
stringlengths 34
39
| size
float64 1
24k
⌀ | message
stringlengths 0
11.5k
⌀ | dataset
stringclasses 1
value |
---|---|---|---|---|---|---|---|---|---|---|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_decompress_single_bit_error (xd3_stream *stream, int expected_non_failures)
{
int ret;
usize_t i;
uint8_t encoded[4*sizeof (test_text)]; /* make room for alt code table */
usize_t encoded_size;
int non_failures = 0;
int cksum = (stream->flags & XD3_ADLER32) != 0;
//#define DEBUG_TEST_FAILURES
#ifndef DEBUG_TEST_FAILURES
#define TEST_FAILURES()
#else
/* For checking non-failure cases by hand, enable this macro and run
* xdelta printdelta with print_cpymode disabled. Every non-failure
* should change a copy address mode, which doesn't cause a failure
* because the address cache starts out with all zeros.
./xdelta3 test
for i in test_text.xz.*; do ./xdelta3 printdelta $i > $i.out;
diff $i.out test_text.xz.0.out; done
*/
system ("rm -rf test_text.*");
{
char buf[TESTBUFSIZE];
FILE *f;
snprintf_func (buf, TESTBUFSIZE, "test_text");
f = fopen (buf, "w");
fwrite (test_text,1,sizeof (test_text),f);
fclose (f);
}
#define TEST_FAILURES() \
do { \
char buf[TESTBUFSIZE]; \
FILE *f; \
snprintf_func (buf, TESTBUFSIZE, "test_text.xz.%d", non_failures); \
f = fopen (buf, "w"); \
fwrite (encoded,1,encoded_size,f); \
fclose (f); \
} while (0)
#endif
stream->sec_data.inefficient = 1;
stream->sec_inst.inefficient = 1;
stream->sec_addr.inefficient = 1;
/* Encode text, test correct input */
if ((ret = test_compress_text (stream, encoded, & encoded_size)))
{
/*stream->msg = "without error: encode failure";*/
return ret;
}
if ((ret = test_decompress_text (stream, encoded, encoded_size,
sizeof (test_text) / 4)))
{
/*stream->msg = "without error: decode failure";*/
return ret;
}
TEST_FAILURES();
for (i = 0; i < encoded_size*8; i += 1)
{
/* Single bit error. */
encoded[i/8] ^= 1 << (i%8);
if ((ret = test_decompress_text (stream, encoded,
encoded_size, sizeof (test_text))) == 0)
{
non_failures += 1;
#ifdef DEBUG_TEST_FAILURES
XPR(NT "%u[%u] non-failure %u\n", i/8, i%8, non_failures);
#endif
TEST_FAILURES();
}
else
{
/*XPR(NT "%u[%u] failure: %s\n", i/8, i%8, stream->msg);*/
}
/* decompress_text returns EIO when the final memcmp() fails, but that
* should never happen with checksumming on. */
if (cksum && ret == EIO)
{
/*XPR(NT "%u[%u] cksum mismatch\n", i/8, i%8);*/
stream->msg = "checksum mismatch";
return XD3_INTERNAL;
}
/* Undo single bit error. */
encoded[i/8] ^= 1 << (i%8);
}
/* Test correct input again */
if ((ret = test_decompress_text (stream, encoded, encoded_size, 1)))
{
/*stream->msg = "without error: decode failure";*/
return ret;
}
/* Check expected non-failures */
if (non_failures != expected_non_failures)
{
XPR(NT "non-failures %u; expected %u",
non_failures, expected_non_failures);
stream->msg = "incorrect";
return XD3_INTERNAL;
}
DOT ();
return 0;
}
|
CWE-119
| null | 516,997 |
71589319189901438649249127948975317819
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_file_stat (main_file *xfile, xoff_t *size)
{
int ret = 0;
#if XD3_WIN32
if (GetFileType(xfile->file) != FILE_TYPE_DISK)
{
return -1;
}
# if (_WIN32_WINNT >= 0x0500)
{
LARGE_INTEGER li;
if (GetFileSizeEx(xfile->file, &li) == 0)
{
return get_errno ();
}
*size = li.QuadPart;
}
# else
{
DWORD filesize = GetFileSize(xfile->file, NULL);
if (filesize == INVALID_FILE_SIZE)
{
return get_errno ()
}
*size = filesize;
}
# endif
#else
struct stat sbuf;
if (fstat (XFNO (xfile), & sbuf) < 0)
{
ret = get_errno ();
return ret;
}
if (! S_ISREG (sbuf.st_mode))
{
return ESPIPE;
}
(*size) = sbuf.st_size;
#endif
return ret;
}
|
CWE-119
| null | 516,998 |
208031341427453648800079558808938203961
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
sec_dist_func4 (xd3_stream *stream, xd3_output *data)
{
int i, ret, x;
for (i = 0; i < ALPHABET_SIZE*20; i += 1)
{
x = mt_exp_rand (10, ALPHABET_SIZE/2);
if ((ret = xd3_emit_byte (stream, & data, x))) { return ret; }
}
return 0;
}
|
CWE-119
| null | 516,999 |
258610341693830230508954812824204342175
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_forward_match (xd3_stream *stream, int unused)
{
usize_t i;
uint8_t buf1[256], buf2[256];
memset(buf1, 0, 256);
memset(buf2, 0, 256);
for (i = 0; i < 256; i++)
{
CHECK(xd3_forward_match(buf1, buf2, i) == (int)i);
}
for (i = 0; i < 255; i++)
{
buf2[i] = 1;
CHECK(xd3_forward_match(buf1, buf2, 256) == (int)i);
buf2[i] = 0;
}
return 0;
}
|
CWE-119
| null | 517,000 |
105125925095199781270376260801776592936
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
xd3_mainerror(int err_num) {
#ifndef _WIN32
const char* x = xd3_strerror (err_num);
if (x != NULL)
{
return x;
}
return strerror(err_num);
#else
static char err_buf[256];
const char* x = xd3_strerror (err_num);
if (x != NULL)
{
return x;
}
memset (err_buf, 0, 256);
FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, err_num,
MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
err_buf, 256, NULL);
if (err_buf[0] != 0 && err_buf[strlen(err_buf) - 1] == '\n')
{
err_buf[strlen(err_buf) - 1] = 0;
}
return err_buf;
#endif
}
|
CWE-119
| null | 517,001 |
82032535942160417804495456639945923206
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_secondary (xd3_stream *stream, const xd3_sec_type *sec, usize_t groups)
{
usize_t test_i;
int ret;
xd3_output *in_head, *out_head, *p;
usize_t p_off, input_size, compress_size;
uint8_t *dec_input = NULL, *dec_output = NULL, *dec_correct = NULL;
xd3_sec_stream *enc_stream;
xd3_sec_cfg cfg;
memset (& cfg, 0, sizeof (cfg));
cfg.inefficient = 1;
for (cfg.ngroups = 1; cfg.ngroups <= groups; cfg.ngroups += 1)
{
XPR(NTR "\n...");
for (test_i = 0; test_i < SIZEOF_ARRAY (sec_dists); test_i += 1)
{
mt_init (& static_mtrand, 0x9f73f7fc);
in_head = xd3_alloc_output (stream, NULL);
out_head = xd3_alloc_output (stream, NULL);
enc_stream = sec->alloc (stream);
dec_input = NULL;
dec_output = NULL;
dec_correct = NULL;
if (in_head == NULL || out_head == NULL || enc_stream == NULL)
{
goto nomem;
}
if ((ret = sec_dists[test_i] (stream, in_head))) { goto fail; }
if ((ret = sec->init (stream, enc_stream, 1)) != 0) { goto fail; }
/* Encode data */
if ((ret = sec->encode (stream, enc_stream,
in_head, out_head, & cfg)))
{
XPR(NT "test %u: encode: %s", test_i, stream->msg);
goto fail;
}
/* Calculate sizes, allocate contiguous arrays for decoding */
input_size = xd3_sizeof_output (in_head);
compress_size = xd3_sizeof_output (out_head);
XPR(NTR "%.3f", 8.0 * (double) compress_size / (double) input_size);
if ((dec_input = (uint8_t*) xd3_alloc (stream, compress_size, 1)) == NULL ||
(dec_output = (uint8_t*) xd3_alloc (stream, input_size, 1)) == NULL ||
(dec_correct = (uint8_t*) xd3_alloc (stream, input_size, 1)) == NULL)
{
goto nomem;
}
/* Fill the compressed data array */
for (p_off = 0, p = out_head; p != NULL;
p_off += p->next, p = p->next_page)
{
memcpy (dec_input + p_off, p->base, p->next);
}
CHECK(p_off == compress_size);
/* Fill the input data array */
for (p_off = 0, p = in_head; p != NULL;
p_off += p->next, p = p->next_page)
{
memcpy (dec_correct + p_off, p->base, p->next);
}
CHECK(p_off == input_size);
if ((ret = test_secondary_decode (stream, sec, input_size,
compress_size, dec_input,
dec_correct, dec_output)))
{
XPR(NT "test %u: decode: %s", test_i, stream->msg);
goto fail;
}
/* Single-bit error test, only cover the first 10 bytes.
* Some non-failures are expected in the Huffman case:
* Changing the clclen array, for example, may not harm the
* decoding. Really looking for faults here. */
{
int i;
int bytes = min (compress_size, 10U);
for (i = 0; i < bytes * 8; i += 1)
{
dec_input[i/8] ^= 1 << (i%8);
if ((ret = test_secondary_decode (stream, sec, input_size,
compress_size, dec_input,
dec_correct, dec_output))
== 0)
{
/*XPR(NT "test %u: decode single-bit [%u/%u]
error non-failure", test_i, i/8, i%8);*/
}
dec_input[i/8] ^= 1 << (i%8);
if ((i % (2*bytes)) == (2*bytes)-1)
{
DOT ();
}
}
ret = 0;
}
if (0) { nomem: ret = ENOMEM; }
fail:
sec->destroy (stream, enc_stream);
xd3_free_output (stream, in_head);
xd3_free_output (stream, out_head);
xd3_free (stream, dec_input);
xd3_free (stream, dec_output);
xd3_free (stream, dec_correct);
if (ret != 0) { return ret; }
}
}
return 0;
}
|
CWE-119
| null | 517,002 |
262225503329426242478314918630971664660
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
reset_defaults(void)
{
option_stdout = 0;
option_force = 0;
option_verbose = DEFAULT_VERBOSE;
option_quiet = 0;
option_appheader = NULL;
option_use_secondary = 0;
option_secondary = NULL;
option_use_altcodetable = 0;
option_smatch_config = NULL;
option_no_compress = 0;
option_no_output = 0;
option_source_filename = NULL;
program_name = NULL;
appheader_used = NULL;
main_bdata = NULL;
main_bsize = 0;
allow_fake_source = 0;
option_smatch_config = NULL;
main_lru_reset();
option_use_appheader = 1;
option_use_checksum = 1;
#if EXTERNAL_COMPRESSION
option_force2 = 0;
option_decompress_inputs = 1;
option_recompress_outputs = 1;
num_subprocs = 0;
#endif
#if VCDIFF_TOOLS
option_print_cpymode = 1;
#endif
option_level = XD3_DEFAULT_LEVEL;
option_iopt_size = XD3_DEFAULT_IOPT_SIZE;
option_winsize = XD3_DEFAULT_WINSIZE;
option_srcwinsz = XD3_DEFAULT_SRCWINSZ;
option_sprevsz = XD3_DEFAULT_SPREVSZ;
}
|
CWE-119
| null | 517,003 |
221350180662254311600861647421302029910
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_format_millis (long millis, shortbuf *buf)
{
if (millis < 1000)
{
short_sprintf (*buf, "%lu ms", millis);
}
else if (millis < 10000)
{
short_sprintf (*buf, "%.1f sec", millis / 1000.0);
}
else
{
short_sprintf (*buf, "%lu sec", millis / 1000L);
}
return buf->buf;
}
|
CWE-119
| null | 517,004 |
122480574555653306594319517528755725440
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_alloc (void *opaque,
size_t items,
usize_t size)
{
return main_malloc1 (items * size);
}
|
CWE-119
| null | 517,005 |
105306298355118336985576857555870970848
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_print_overflow (int x)
{
XPR(NT "internal print buffer overflow: %d bytes\n", x);
return XD3_INTERNAL;
}
|
CWE-119
| null | 517,006 |
130839441949249251011301137905959457723
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_free (void *ptr)
{
if (ptr)
{
IF_DEBUG (main_mallocs -= 1);
main_free1 (NULL, ptr);
IF_DEBUG (XD3_ASSERT(main_mallocs >= 0));
}
}
|
CWE-119
| null | 517,007 |
234201140568891682740272250890423887064
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
xprintf (const char *fmt, ...)
{
char buf[1000];
va_list a;
int size;
va_start (a, fmt);
size = vsnprintf_func (buf, 1000, fmt, a);
va_end (a);
if (size < 0)
{
size = sizeof(buf) - 1;
buf[size] = 0;
}
if (xprintf_message_func != NULL) {
xprintf_message_func(buf);
} else {
size_t ignore = fwrite(buf, 1, size, stderr);
(void) ignore;
}
}
|
CWE-119
| null | 517,008 |
113645736462942314591640100022937423419
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_format_bcnt (xoff_t r, shortbuf *buf)
{
static const char* fmts[] = { "B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB" };
usize_t i;
for (i = 0; i < SIZEOF_ARRAY(fmts) - 1; i += 1)
{
xoff_t new_r;
if (r == 0)
{
short_sprintf (*buf, "0 %s", fmts[i]);
return buf->buf;
}
if (r >= 1 && r < 10)
{
short_sprintf (*buf, "%.2f %s", (double) r, fmts[i]);
return buf->buf;
}
if (r >= 10 && r < 100)
{
short_sprintf (*buf, "%.1f %s", (double) r, fmts[i]);
return buf->buf;
}
if (r >= 100 && r < 1000)
{
short_sprintf (*buf, "%"Q"u %s", r, fmts[i]);
return buf->buf;
}
new_r = r / 1024;
if (new_r < 10)
{
short_sprintf (*buf, "%.2f %s", (double) r / 1024.0, fmts[i + 1]);
return buf->buf;
}
if (new_r < 100)
{
short_sprintf (*buf, "%.1f %s", (double) r / 1024.0, fmts[i + 1]);
return buf->buf;
}
r = new_r;
}
XD3_ASSERT (0);
return "";
}
|
CWE-119
| null | 517,009 |
106102585448563406932551207363186118804
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_force_behavior (xd3_stream *stream, int ignore)
{
int ret;
char buf[TESTBUFSIZE];
/* Create empty target file */
test_setup ();
snprintf_func (buf, TESTBUFSIZE, "cp /dev/null %s", TEST_TARGET_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Encode to delta file */
snprintf_func (buf, TESTBUFSIZE, "%s -e %s %s", program_name,
TEST_TARGET_FILE, TEST_DELTA_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Encode again, should fail. */
snprintf_func (buf, TESTBUFSIZE, "%s -q -e %s %s ", program_name,
TEST_TARGET_FILE, TEST_DELTA_FILE);
if ((ret = do_fail (stream, buf))) { return ret; }
/* Force it, should succeed. */
snprintf_func (buf, TESTBUFSIZE, "%s -f -e %s %s", program_name,
TEST_TARGET_FILE, TEST_DELTA_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
test_cleanup();
return 0;
}
|
CWE-119
| null | 517,010 |
301557004958559627486348277184075946305
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_get_appheader_params (main_file *file, char **parsed,
int output, const char *type,
main_file *other)
{
/* Set the filename if it was not specified. If output, option_stdout (-c)
* overrides. */
if (file->filename == NULL &&
! (output && option_stdout) &&
strcmp (parsed[0], "-") != 0)
{
file->filename = parsed[0];
if (other->filename != NULL) {
/* Take directory from the other file, if it has one. */
/* TODO: This results in nonsense names like /dev/foo.tar.gz
* and probably the filename-default logic interferes with
* multi-file operation and the standard file extension?
* Possibly the name header is bad, should be off by default.
* Possibly we just want to remember external/compression
* settings. */
const char *last_slash = strrchr(other->filename, '/');
if (last_slash != NULL) {
usize_t dlen = (usize_t) (last_slash - other->filename);
XD3_ASSERT(file->filename_copy == NULL);
file->filename_copy =
(char*) main_malloc(dlen + 2 + (usize_t) strlen(file->filename));
strncpy(file->filename_copy, other->filename, dlen);
file->filename_copy[dlen] = '/';
strcpy(file->filename_copy + dlen + 1, parsed[0]);
file->filename = file->filename_copy;
}
}
if (! option_quiet)
{
XPR(NT "using default %s filename: %s\n", type, file->filename);
}
}
/* Set the compressor, initiate de/recompression later. */
if (file->compressor == NULL && *parsed[1] != 0)
{
file->flags |= RD_DECOMPSET;
file->compressor = main_get_compressor (parsed[1]);
}
}
|
CWE-119
| null | 517,011 |
262047654452555988093386279053236880911
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_file_seek (main_file *xfile, xoff_t pos)
{
int ret = 0;
#if XD3_STDIO
if (fseek (xfile->file, pos, SEEK_SET) != 0) { ret = get_errno (); }
#elif XD3_POSIX
if ((xoff_t) lseek (xfile->file, pos, SEEK_SET) != pos)
{ ret = get_errno (); }
#elif XD3_WIN32
# if (_WIN32_WINNT >= 0x0500)
LARGE_INTEGER move, out;
move.QuadPart = pos;
if (SetFilePointerEx(xfile->file, move, &out, FILE_BEGIN) == 0)
{
ret = get_errno ();
}
# else
if (SetFilePointer(xfile->file, (LONG)pos, NULL, FILE_BEGIN) ==
INVALID_SET_FILE_POINTER)
{
ret = get_errno ();
}
# endif
#endif
return ret;
}
|
CWE-119
| null | 517,012 |
60001362893746090555681991033363488638
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_stdout_behavior (xd3_stream *stream, int ignore)
{
int ret;
char buf[TESTBUFSIZE];
test_setup();
snprintf_func (buf, TESTBUFSIZE, "cp /dev/null %s", TEST_TARGET_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Without -c, encode writes to delta file */
snprintf_func (buf, TESTBUFSIZE, "%s -e %s %s", program_name,
TEST_TARGET_FILE, TEST_DELTA_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* With -c, encode writes to stdout */
snprintf_func (buf, TESTBUFSIZE, "%s -e -c %s > %s", program_name,
TEST_TARGET_FILE, TEST_DELTA_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Without -c, decode writes to target file name, but it fails because the
* file exists. */
snprintf_func (buf, TESTBUFSIZE, "%s -q -d %s ", program_name, TEST_DELTA_FILE);
if ((ret = do_fail (stream, buf))) { return ret; }
/* With -c, decode writes to stdout */
snprintf_func (buf, TESTBUFSIZE, "%s -d -c %s > /dev/null", program_name, TEST_DELTA_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
test_cleanup();
return 0;
}
|
CWE-119
| null | 517,013 |
114382739921061616422739782638375330879
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_get_winsize (main_file *ifile) {
xoff_t file_size = 0;
usize_t size = option_winsize;
static shortbuf iszbuf;
if (main_file_stat (ifile, &file_size) == 0)
{
size = (usize_t) min(file_size, (xoff_t) size);
}
size = max(size, XD3_ALLOCSIZE);
if (option_verbose > 1)
{
XPR(NT "input %s window size %s\n",
ifile->filename,
main_format_bcnt (size, &iszbuf));
}
return size;
}
|
CWE-119
| null | 517,014 |
315583535165977189596454511131153772724
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_external_compression_cleanup (void)
{
int i;
for (i = 0; i < num_subprocs; i += 1)
{
if (! ext_subprocs[i]) { continue; }
kill (ext_subprocs[i], SIGTERM);
ext_subprocs[i] = 0;
}
}
|
CWE-119
| null | 517,015 |
107089829208007421884301371216026178150
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_string_matching (xd3_stream *stream, int ignore)
{
usize_t i;
int ret;
xd3_config config;
char rbuf[TESTBUFSIZE];
for (i = 0; i < SIZEOF_ARRAY (match_tests); i += 1)
{
const string_match_test *test = & match_tests[i];
char *rptr = rbuf;
usize_t len = (usize_t) strlen (test->input);
xd3_free_stream (stream);
xd3_init_config (& config, 0);
config.smatch_cfg = XD3_SMATCH_SOFT;
config.smatcher_soft.large_look = 4;
config.smatcher_soft.large_step = 4;
config.smatcher_soft.small_look = 4;
config.smatcher_soft.small_chain = 10;
config.smatcher_soft.small_lchain = 10;
config.smatcher_soft.max_lazy = (test->flags & SM_LAZY) ? 10 : 0;
config.smatcher_soft.long_enough = 10;
if ((ret = xd3_config_stream (stream, & config))) { return ret; }
if ((ret = xd3_encode_init_full (stream))) { return ret; }
xd3_avail_input (stream, (uint8_t*)test->input, len);
if ((ret = stream->smatcher.string_match (stream))) { return ret; }
*rptr = 0;
while (! xd3_rlist_empty (& stream->iopt_used))
{
xd3_rinst *inst = xd3_rlist_pop_front (& stream->iopt_used);
switch (inst->type)
{
case XD3_RUN: *rptr++ = 'R'; break;
case XD3_CPY: *rptr++ = 'C'; break;
default: CHECK(0);
}
snprintf_func (rptr, rbuf+TESTBUFSIZE-rptr, "%d/%d",
inst->pos, inst->size);
rptr += strlen (rptr);
if (inst->type == XD3_CPY)
{
*rptr++ = '@';
snprintf_func (rptr, rbuf+TESTBUFSIZE-rptr, "%"Q"d", inst->addr);
rptr += strlen (rptr);
}
*rptr++ = ' ';
xd3_rlist_push_back (& stream->iopt_free, inst);
}
if (rptr != rbuf)
{
rptr -= 1; *rptr = 0;
}
if (strcmp (rbuf, test->result) != 0)
{
XPR(NT "test %u: expected %s: got %s", i, test->result, rbuf);
stream->msg = "wrong result";
return XD3_INTERNAL;
}
}
return 0;
}
|
CWE-119
| null | 517,016 |
259568242345369351638823980289244645350
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_compressed_pipe (xd3_stream *stream, main_extcomp *ext, char* buf,
const char* comp_options, const char* decomp_options,
int do_ext_recomp, const char* msg)
{
int ret;
char decomp_buf[TESTBUFSIZE];
if (do_ext_recomp)
{
snprintf_func (decomp_buf, TESTBUFSIZE,
" | %s %s", ext->decomp_cmdname, ext->decomp_options);
}
else
{
decomp_buf[0] = 0;
}
snprintf_func (buf, TESTBUFSIZE, "%s %s < %s | %s %s | %s %s%s > %s",
ext->recomp_cmdname, ext->recomp_options,
TEST_TARGET_FILE,
program_name, comp_options,
program_name, decomp_options,
decomp_buf,
TEST_RECON_FILE);
if ((ret = system (buf)) != 0)
{
stream->msg = msg;
return XD3_INTERNAL;
}
if ((ret = test_compare_files (TEST_TARGET_FILE, TEST_RECON_FILE)))
{
return XD3_INTERNAL;
}
DOT ();
return 0;
}
|
CWE-119
| null | 517,017 |
9980589885031933928459257174962494724
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
get_errno (void)
{
#ifndef _WIN32
if (errno == 0)
{
XPR(NT "you found a bug: expected errno != 0\n");
errno = XD3_INTERNAL;
}
return errno;
#else
DWORD err_num = GetLastError();
if (err_num == NO_ERROR)
{
err_num = XD3_INTERNAL;
}
return err_num;
#endif
}
|
CWE-119
| null | 517,018 |
169231653317294877551575509631261463127
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
void mt_init(mtrand *mt, uint32_t seed) {
int i;
mt->mt_buffer_[0] = seed;
mt->mt_index_ = MT_LEN;
for (i = 1; i < MT_LEN; i++) {
/* See Knuth TAOCP Vol2. 3rd Ed. P.106 for multiplier. */
/* In the previous versions, MSBs of the seed affect */
/* only MSBs of the array mt[]. */
/* 2002/01/09 modified by Makoto Matsumoto */
mt->mt_buffer_[i] =
(1812433253UL * (mt->mt_buffer_[i-1] ^
(mt->mt_buffer_[i-1] >> 30)) + i);
}
}
|
CWE-119
| null | 517,019 |
324242179256810563127454873813335609184
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
sec_dist_func5 (xd3_stream *stream, xd3_output *data)
{
int i, ret, x;
for (i = 0; i < ALPHABET_SIZE*20; i += 1)
{
x = mt_exp_rand (10, ALPHABET_SIZE-1);
if ((ret = xd3_emit_byte (stream, & data, x))) { return ret; }
}
return 0;
}
|
CWE-119
| null | 517,020 |
2242636496305183835226976601426238432
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
xsnprintf_func (char *str, int n, const char *fmt, ...)
{
va_list a;
int ret;
va_start (a, fmt);
ret = vsnprintf_func (str, n, fmt, a);
va_end (a);
if (ret < 0)
{
ret = n;
}
return ret;
}
|
CWE-119
| null | 517,021 |
307211492713843396515518523067312378139
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_source_cksum_offset (xd3_stream *stream, int ignore)
{
xd3_source source;
// Inputs are:
struct {
xoff_t cpos; // stream->srcwin_cksum_pos;
xoff_t ipos; // stream->total_in;
xoff_t size; // stream->src->size;
usize_t input; // input 32-bit offset
xoff_t output; // output 64-bit offset
} cksum_test[] = {
// If cpos is <= 2^32
{ 1, 1, 1, 1, 1 },
#if XD3_USE_LARGEFILE64
// cpos ipos size input output
// 0x____xxxxxULL, 0x____xxxxxULL, 0x____xxxxxULL, 0x___xxxxxUL, 0x____xxxxxULL
{ 0x100100000ULL, 0x100000000ULL, 0x100200000ULL, 0x00000000UL, 0x100000000ULL },
{ 0x100100000ULL, 0x100000000ULL, 0x100200000ULL, 0xF0000000UL, 0x0F0000000ULL },
{ 0x100200000ULL, 0x100100000ULL, 0x100200000ULL, 0x00300000UL, 0x000300000ULL },
{ 25771983104ULL, 25770000000ULL, 26414808769ULL, 2139216707UL, 23614053187ULL },
#endif
{ 0, 0, 0, 0, 0 },
}, *test_ptr;
stream->src = &source;
for (test_ptr = cksum_test; test_ptr->cpos; test_ptr++) {
xoff_t r;
stream->srcwin_cksum_pos = test_ptr->cpos;
stream->total_in = test_ptr->ipos;
r = xd3_source_cksum_offset(stream, test_ptr->input);
CHECK(r == test_ptr->output);
}
return 0;
}
|
CWE-119
| null | 517,022 |
337824178433479459058138131972685273556
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
void* main_bufalloc (size_t size) {
#if XD3_WIN32
return VirtualAlloc(NULL, size, MEM_COMMIT | MEM_RESERVE, PAGE_READWRITE);
#else
return main_malloc1(size);
#endif
}
|
CWE-119
| null | 517,023 |
310458143138035495837481031205914729102
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_malloc1 (size_t size)
{
void* r = malloc (size);
if (r == NULL) { XPR(NT "malloc: %s\n", xd3_mainerror (ENOMEM)); }
return r;
}
|
CWE-119
| null | 517,024 |
70603917099119154884585054042776526491
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_secondary_decode (xd3_stream *stream,
const xd3_sec_type *sec,
usize_t input_size,
usize_t compress_size,
const uint8_t *dec_input,
const uint8_t *dec_correct,
uint8_t *dec_output)
{
int ret;
xd3_sec_stream *dec_stream;
const uint8_t *dec_input_used, *dec_input_end;
uint8_t *dec_output_used, *dec_output_end;
if ((dec_stream = sec->alloc (stream)) == NULL) { return ENOMEM; }
if ((ret = sec->init (stream, dec_stream, 0)) != 0) { goto fail; }
dec_input_used = dec_input;
dec_input_end = dec_input + compress_size;
dec_output_used = dec_output;
dec_output_end = dec_output + input_size;
if ((ret = sec->decode (stream, dec_stream,
& dec_input_used, dec_input_end,
& dec_output_used, dec_output_end)))
{
goto fail;
}
if (dec_input_used != dec_input_end)
{
stream->msg = "unused input";
ret = XD3_INTERNAL;
goto fail;
}
if (dec_output_used != dec_output_end)
{
stream->msg = "unfinished output";
ret = XD3_INTERNAL;
goto fail;
}
if (memcmp (dec_output, dec_correct, input_size) != 0)
{
stream->msg = "incorrect output";
ret = XD3_INTERNAL;
goto fail;
}
fail:
sec->destroy (stream, dec_stream);
return ret;
}
|
CWE-119
| null | 517,025 |
88382288740271125171669910357538600640
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_source_decompression (xd3_stream *stream, int ignore)
{
int ret;
char buf[TESTBUFSIZE];
const main_extcomp *ext;
xoff_t dsize;
mt_init (& static_mtrand, 0x9f73f7fc);
test_setup ();
if ((ret = test_make_inputs (stream, NULL, NULL))) { return ret; }
/* Use gzip. */
if ((ext = main_get_compressor ("G")) == NULL)
{
XPR(NT "skipped");
return 0;
}
/* Save an uncompressed copy. */
if ((ret = test_save_copy (TEST_TARGET_FILE))) { return ret; }
/* Compress the source. */
snprintf_func (buf, TESTBUFSIZE, "%s -1 %s < %s > %s", ext->recomp_cmdname,
ext->recomp_options, TEST_COPY_FILE, TEST_SOURCE_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Compress the target. */
snprintf_func (buf, TESTBUFSIZE, "%s -9 %s < %s > %s", ext->recomp_cmdname,
ext->recomp_options, TEST_COPY_FILE, TEST_TARGET_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Now the two identical files are compressed. Delta-encode the target,
* with decompression. */
snprintf_func (buf, TESTBUFSIZE, "%s -e -vfq -s%s %s %s", program_name, TEST_SOURCE_FILE,
TEST_TARGET_FILE, TEST_DELTA_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Check that the compressed file is small (b/c inputs are
* identical). */
if ((ret = test_file_size (TEST_DELTA_FILE, & dsize))) { return ret; }
/* Deltas for identical files should be very small. */
if (dsize > 200)
{
XPR(NT "external compression did not happen\n");
stream->msg = "external compression did not happen";
return XD3_INTERNAL;
}
/* Decode the delta file with recompression disabled, should get an
* uncompressed file out. */
snprintf_func (buf, TESTBUFSIZE, "%s -v -dq -R -s%s %s %s", program_name,
TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
if ((ret = test_compare_files (TEST_COPY_FILE,
TEST_RECON_FILE))) { return ret; }
/* Decode the delta file with recompression, should get a compressed file
* out. But we can't compare compressed files directly. */
snprintf_func (buf, TESTBUFSIZE, "%s -v -dqf -s%s %s %s", program_name,
TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
snprintf_func (buf, TESTBUFSIZE, "%s %s < %s > %s", ext->decomp_cmdname, ext->decomp_options,
TEST_RECON_FILE, TEST_RECON2_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
if ((ret = test_compare_files (TEST_COPY_FILE,
TEST_RECON2_FILE))) { return ret; }
/* Encode with decompression disabled */
snprintf_func (buf, TESTBUFSIZE, "%s -e -D -vfq -s%s %s %s", program_name,
TEST_SOURCE_FILE, TEST_TARGET_FILE, TEST_DELTA_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
/* Decode the delta file with decompression disabled, should get the
* identical compressed file out. */
snprintf_func (buf, TESTBUFSIZE, "%s -d -D -vfq -s%s %s %s", program_name,
TEST_SOURCE_FILE, TEST_DELTA_FILE, TEST_RECON_FILE);
if ((ret = do_cmd (stream, buf))) { return ret; }
if ((ret = test_compare_files (TEST_TARGET_FILE,
TEST_RECON_FILE))) { return ret; }
test_cleanup();
return 0;
}
|
CWE-119
| null | 517,026 |
234439128096351053262418163509428949066
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
sec_dist_func3 (xd3_stream *stream, xd3_output *data)
{
int i, ret;
for (i = 0; i < ALPHABET_SIZE; i += 1)
{
if ((ret = xd3_emit_byte (stream, & data, i%ALPHABET_SIZE))) { return ret; }
}
return 0;
}
|
CWE-119
| null | 517,027 |
232676511526991536369046712319539602687
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
test_compare_files (const char* tgt, const char *rec)
{
FILE *orig, *recons;
static uint8_t obuf[TESTBUFSIZE], rbuf[TESTBUFSIZE];
xoff_t offset = 0;
size_t i;
size_t oc, rc;
xoff_t diffs = 0;
if ((orig = fopen (tgt, "r")) == NULL)
{
XPR(NT "open %s failed\n", tgt);
return get_errno ();
}
if ((recons = fopen (rec, "r")) == NULL)
{
XPR(NT "open %s failed\n", rec);
return get_errno ();
}
for (;;)
{
oc = fread (obuf, 1, TESTBUFSIZE, orig);
rc = fread (rbuf, 1, TESTBUFSIZE, recons);
if (oc != rc)
{
return XD3_INTERNAL;
}
if (oc == 0)
{
break;
}
for (i = 0; i < oc; i += 1)
{
if (obuf[i] != rbuf[i])
{
XPR(NT "byte %u (read %u @ %"Q"u) %d != %d\n",
(int)i, (int)oc, offset, obuf[i], rbuf[i]);
diffs++;
return XD3_INTERNAL;
}
}
offset += oc;
}
fclose (orig);
fclose (recons);
if (diffs != 0)
{
return XD3_INTERNAL;
}
return 0;
}
|
CWE-119
| null | 517,028 |
288477258120971106264919262361772681318
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_init_recode_stream (void)
{
int ret;
int stream_flags = XD3_ADLER32_NOVER | XD3_SKIP_EMIT;
int recode_flags;
xd3_config recode_config;
XD3_ASSERT (recode_stream == NULL);
if ((recode_stream = (xd3_stream*) main_malloc(sizeof(xd3_stream))) == NULL)
{
return ENOMEM;
}
recode_flags = (stream_flags & XD3_SEC_TYPE);
recode_config.alloc = main_alloc;
recode_config.freef = main_free1;
xd3_init_config(&recode_config, recode_flags);
if ((ret = main_set_secondary_flags (&recode_config)) ||
(ret = xd3_config_stream (recode_stream, &recode_config)) ||
(ret = xd3_encode_init_partial (recode_stream)) ||
(ret = xd3_whole_state_init (recode_stream)))
{
XPR(NT XD3_LIB_ERRMSG (recode_stream, ret));
xd3_free_stream (recode_stream);
recode_stream = NULL;
return ret;
}
return 0;
}
|
CWE-119
| null | 517,029 |
230654235111700694759143098175972451204
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_external_compression_finish (void)
{
int i;
int ret;
for (i = 0; i < num_subprocs; i += 1)
{
if (! ext_subprocs[i]) { continue; }
if ((ret = main_waitpid_check (ext_subprocs[i])))
{
return ret;
}
ext_subprocs[i] = 0;
}
return 0;
}
|
CWE-119
| null | 517,030 |
95883746976758795627090053238808810420
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_get_compressor (const char *ident)
{
const main_extcomp *ext = main_ident_compressor (ident);
if (ext == NULL)
{
if (! option_quiet)
{
XPR(NT "warning: cannot recompress output: "
"unrecognized external compression ID: %s\n", ident);
}
return NULL;
}
else if (! EXTERNAL_COMPRESSION)
{
if (! option_quiet)
{
XPR(NT "warning: external support not compiled: "
"original input was compressed: %s\n", ext->recomp_cmdname);
}
return NULL;
}
else
{
return ext;
}
}
|
CWE-119
| null | 517,031 |
206706358018124626563329678993641153214
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
xd3_selftest (void)
{
#define DO_TEST(fn,flags,arg) \
do { \
xd3_stream stream; \
xd3_config config; \
xd3_init_config (& config, flags); \
XPR(NT "testing " #fn "%s...", \
flags ? (" (" #flags ")") : ""); \
if ((ret = xd3_config_stream (& stream, & config) == 0) && \
(ret = test_ ## fn (& stream, arg)) == 0) { \
XPR(NTR " success\n"); \
} else { \
XPR(NTR " failed: %s: %s\n", xd3_errstring (& stream), \
xd3_mainerror (ret)); } \
xd3_free_stream (& stream); \
if (ret != 0) { goto failure; } \
} while (0)
int ret;
DO_TEST (random_numbers, 0, 0);
DO_TEST (decode_integer_end_of_input, 0, 0);
DO_TEST (decode_integer_overflow, 0, 0);
DO_TEST (encode_decode_uint32_t, 0, 0);
DO_TEST (encode_decode_uint64_t, 0, 0);
DO_TEST (usize_t_overflow, 0, 0);
DO_TEST (forward_match, 0, 0);
DO_TEST (address_cache, 0, 0);
IF_GENCODETBL (DO_TEST (address_cache, XD3_ALT_CODE_TABLE, 0));
DO_TEST (string_matching, 0, 0);
DO_TEST (choose_instruction, 0, 0);
DO_TEST (identical_behavior, 0, 0);
DO_TEST (in_memory, 0, 0);
IF_GENCODETBL (DO_TEST (choose_instruction, XD3_ALT_CODE_TABLE, 0));
IF_GENCODETBL (DO_TEST (encode_code_table, 0, 0));
DO_TEST (iopt_flush_instructions, 0, 0);
DO_TEST (source_cksum_offset, 0, 0);
DO_TEST (decompress_single_bit_error, 0, 3);
DO_TEST (decompress_single_bit_error, XD3_ADLER32, 3);
IF_LZMA (DO_TEST (decompress_single_bit_error, XD3_SEC_LZMA, 54));
IF_FGK (DO_TEST (decompress_single_bit_error, XD3_SEC_FGK, 3));
IF_DJW (DO_TEST (decompress_single_bit_error, XD3_SEC_DJW, 8));
/* There are many expected non-failures for ALT_CODE_TABLE because
* not all of the instruction codes are used. */
IF_GENCODETBL (
DO_TEST (decompress_single_bit_error, XD3_ALT_CODE_TABLE, 224));
#if SHELL_TESTS
DO_TEST (force_behavior, 0, 0);
DO_TEST (stdout_behavior, 0, 0);
DO_TEST (no_output, 0, 0);
DO_TEST (appheader, 0, 0);
DO_TEST (command_line_arguments, 0, 0);
#if EXTERNAL_COMPRESSION
DO_TEST (source_decompression, 0, 0);
DO_TEST (externally_compressed_io, 0, 0);
#endif
DO_TEST (recode_command, 0, 0);
#endif
IF_LZMA (DO_TEST (secondary_lzma, 0, 1));
IF_DJW (DO_TEST (secondary_huff, 0, DJW_MAX_GROUPS));
IF_FGK (DO_TEST (secondary_fgk, 0, 1));
DO_TEST (compressed_stream_overflow, 0, 0);
IF_LZMA (DO_TEST (compressed_stream_overflow, XD3_SEC_LZMA, 0));
failure:
test_cleanup ();
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
#undef DO_TEST
}
|
CWE-119
| null | 517,032 |
284587885046297631724469526169785600887
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
static int do_cmd (xd3_stream *stream, const char *buf)
{
int ret;
if ((ret = system (buf)) != 0)
{
if (WIFEXITED (ret))
{
stream->msg = "command exited non-zero";
IF_DEBUG1 (XPR(NT "command was: %s\n", buf));
}
else
{
stream->msg = "abnormal command termination";
}
return ret;
}
return 0;
}
|
CWE-119
| null | 517,033 |
6549052211191654717056826811838020370
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
int test_setup (void)
{
static int x = 0;
x++;
snprintf_func (TEST_TARGET_FILE, TESTFILESIZE, "/tmp/xdtest.target.%d", x);
snprintf_func (TEST_SOURCE_FILE, TESTFILESIZE, "/tmp/xdtest.source.%d", x);
snprintf_func (TEST_DELTA_FILE, TESTFILESIZE, "/tmp/xdtest.delta.%d", x);
snprintf_func (TEST_RECON_FILE, TESTFILESIZE, "/tmp/xdtest.recon.%d", x);
snprintf_func (TEST_RECON2_FILE, TESTFILESIZE, "/tmp/xdtest.recon2.%d", x);
snprintf_func (TEST_COPY_FILE, TESTFILESIZE, "/tmp/xdtest.copy.%d", x);
snprintf_func (TEST_NOPERM_FILE, TESTFILESIZE, "/tmp/xdtest.noperm.%d", x);
test_cleanup();
return 0;
}
|
CWE-119
| null | 517,034 |
295466493811187797319387884292461493772
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_file_close (main_file *xfile)
{
int ret = 0;
if (! main_file_isopen (xfile))
{
return 0;
}
#if XD3_STDIO
ret = fclose (xfile->file);
xfile->file = NULL;
#elif XD3_POSIX
ret = close (xfile->file);
xfile->file = -1;
#elif XD3_WIN32
if (!CloseHandle(xfile->file)) {
ret = get_errno ();
}
xfile->file = INVALID_HANDLE_VALUE;
#endif
if (ret != 0) { XF_ERROR ("close", xfile->filename, ret = get_errno ()); }
return ret;
}
|
CWE-119
| null | 517,035 |
63922195175044839355008991625032309888
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
sec_dist_func6 (xd3_stream *stream, xd3_output *data)
{
int i, ret, x;
for (i = 0; i < ALPHABET_SIZE*20; i += 1)
{
x = mt_random (&static_mtrand) % (ALPHABET_SIZE/2);
if ((ret = xd3_emit_byte (stream, & data, x))) { return ret; }
}
return 0;
}
|
CWE-119
| null | 517,036 |
107436125753311363454864040657642640818
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_get_appheader (xd3_stream *stream, main_file *ifile,
main_file *output, main_file *sfile)
{
uint8_t *apphead;
usize_t appheadsz;
int ret;
/* The user may disable the application header. Once the appheader
* is set, this disables setting it again. */
if (! option_use_appheader) { return; }
ret = xd3_get_appheader (stream, & apphead, & appheadsz);
/* Ignore failure, it only means we haven't received a header yet. */
if (ret != 0) { return; }
if (appheadsz > 0)
{
const int kMaxArgs = 4;
char *start = (char*)apphead;
char *slash;
int place = 0;
char *parsed[kMaxArgs];
memset (parsed, 0, sizeof (parsed));
while ((slash = strchr (start, '/')) != NULL && place < (kMaxArgs-1))
{
*slash = 0;
parsed[place++] = start;
start = slash + 1;
}
parsed[place++] = start;
/* First take the output parameters. */
if (place == 2 || place == 4)
{
main_get_appheader_params (output, parsed, 1, "output", ifile);
}
/* Then take the source parameters. */
if (place == 4)
{
main_get_appheader_params (sfile, parsed+2, 0, "source", ifile);
}
}
option_use_appheader = 0;
return;
}
|
CWE-119
| null | 517,037 |
191465324098688620085127977280830394703
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_set_appheader (xd3_stream *stream, main_file *input, main_file *sfile)
{
/* The user may disable the application header. Once the appheader
* is set, this disables setting it again. */
if (appheader_used || ! option_use_appheader) { return 0; }
/* The user may specify the application header, otherwise format the
default header. */
if (option_appheader)
{
appheader_used = option_appheader;
}
else
{
const char *iname;
const char *icomp;
const char *sname;
const char *scomp;
usize_t len;
iname = main_apphead_string (input->filename);
icomp = (input->compressor == NULL) ? "" : input->compressor->ident;
len = (usize_t) strlen (iname) + (usize_t) strlen (icomp) + 2;
if (sfile->filename != NULL)
{
sname = main_apphead_string (sfile->filename);
scomp = (sfile->compressor == NULL) ? "" : sfile->compressor->ident;
len += (usize_t) strlen (sname) + (usize_t) strlen (scomp) + 2;
}
else
{
sname = scomp = "";
}
if ((appheader_used = (uint8_t*) main_malloc (len)) == NULL)
{
return ENOMEM;
}
if (sfile->filename == NULL)
{
snprintf_func ((char*)appheader_used, len, "%s/%s", iname, icomp);
}
else
{
snprintf_func ((char*)appheader_used, len, "%s/%s/%s/%s",
iname, icomp, sname, scomp);
}
}
xd3_set_appheader (stream, appheader_used,
(usize_t) strlen ((char*)appheader_used));
return 0;
}
|
CWE-119
| null | 517,038 |
33081074230894725202713932109159640091
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_config (void)
{
main_version ();
XPR(NTR "EXTERNAL_COMPRESSION=%d\n", EXTERNAL_COMPRESSION);
XPR(NTR "GENERIC_ENCODE_TABLES=%d\n", GENERIC_ENCODE_TABLES);
XPR(NTR "GENERIC_ENCODE_TABLES_COMPUTE=%d\n", GENERIC_ENCODE_TABLES_COMPUTE);
XPR(NTR "REGRESSION_TEST=%d\n", REGRESSION_TEST);
XPR(NTR "SECONDARY_DJW=%d\n", SECONDARY_DJW);
XPR(NTR "SECONDARY_FGK=%d\n", SECONDARY_FGK);
XPR(NTR "SECONDARY_LZMA=%d\n", SECONDARY_LZMA);
XPR(NTR "UNALIGNED_OK=%d\n", UNALIGNED_OK);
XPR(NTR "VCDIFF_TOOLS=%d\n", VCDIFF_TOOLS);
XPR(NTR "XD3_ALLOCSIZE=%d\n", XD3_ALLOCSIZE);
XPR(NTR "XD3_DEBUG=%d\n", XD3_DEBUG);
XPR(NTR "XD3_ENCODER=%d\n", XD3_ENCODER);
XPR(NTR "XD3_POSIX=%d\n", XD3_POSIX);
XPR(NTR "XD3_STDIO=%d\n", XD3_STDIO);
XPR(NTR "XD3_WIN32=%d\n", XD3_WIN32);
XPR(NTR "XD3_USE_LARGEFILE64=%d\n", XD3_USE_LARGEFILE64);
XPR(NTR "XD3_DEFAULT_LEVEL=%d\n", XD3_DEFAULT_LEVEL);
XPR(NTR "XD3_DEFAULT_IOPT_SIZE=%d\n", XD3_DEFAULT_IOPT_SIZE);
XPR(NTR "XD3_DEFAULT_SPREVSZ=%d\n", XD3_DEFAULT_SPREVSZ);
XPR(NTR "XD3_DEFAULT_SRCWINSZ=%d\n", XD3_DEFAULT_SRCWINSZ);
XPR(NTR "XD3_DEFAULT_WINSIZE=%d\n", XD3_DEFAULT_WINSIZE);
XPR(NTR "XD3_HARDMAXWINSIZE=%d\n", XD3_HARDMAXWINSIZE);
XPR(NTR "sizeof(void*)=%d\n", (int)sizeof(void*));
XPR(NTR "sizeof(int)=%d\n", (int)sizeof(int));
XPR(NTR "sizeof(size_t)=%d\n", (int)sizeof(size_t));
XPR(NTR "sizeof(uint32_t)=%d\n", (int)sizeof(uint32_t));
XPR(NTR "sizeof(uint64_t)=%d\n", (int)sizeof(uint64_t));
XPR(NTR "sizeof(usize_t)=%d\n", (int)sizeof(usize_t));
XPR(NTR "sizeof(xoff_t)=%d\n", (int)sizeof(xoff_t));
return EXIT_SUCCESS;
}
|
CWE-119
| null | 517,039 |
150469262831963689413672572866238481676
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_merge_arguments (main_merge_list* merges)
{
int ret = 0;
int count = 0;
main_merge *merge = NULL;
xd3_stream merge_input;
if (main_merge_list_empty (merges))
{
return 0;
}
if ((ret = xd3_config_stream (& merge_input, NULL)) ||
(ret = xd3_whole_state_init (& merge_input)))
{
XPR(NT XD3_LIB_ERRMSG (& merge_input, ret));
return ret;
}
merge = main_merge_list_front (merges);
while (!main_merge_list_end (merges, merge))
{
main_file mfile;
main_file_init (& mfile);
mfile.filename = merge->filename;
mfile.flags = RD_NONEXTERNAL;
if ((ret = main_file_open (& mfile, merge->filename, XO_READ)))
{
goto error;
}
ret = main_input (CMD_MERGE_ARG, & mfile, NULL, NULL);
if (ret == 0)
{
if (count++ == 0)
{
/* The first merge source is the next merge input. */
xd3_swap_whole_state (& recode_stream->whole_target,
& merge_input.whole_target);
}
else
{
/* Merge the recode_stream with merge_input. */
ret = xd3_merge_input_output (recode_stream,
& merge_input.whole_target);
/* Save the next merge source in merge_input. */
xd3_swap_whole_state (& recode_stream->whole_target,
& merge_input.whole_target);
}
}
main_file_cleanup (& mfile);
if (recode_stream != NULL)
{
xd3_free_stream (recode_stream);
main_free (recode_stream);
recode_stream = NULL;
}
if (main_bdata != NULL)
{
main_buffree (main_bdata);
main_bdata = NULL;
main_bsize = 0;
}
if (ret != 0)
{
goto error;
}
merge = main_merge_list_next (merge);
}
XD3_ASSERT (merge_stream == NULL);
if ((merge_stream = (xd3_stream*) main_malloc (sizeof(xd3_stream))) == NULL)
{
ret = ENOMEM;
goto error;
}
if ((ret = xd3_config_stream (merge_stream, NULL)) ||
(ret = xd3_whole_state_init (merge_stream)))
{
XPR(NT XD3_LIB_ERRMSG (& merge_input, ret));
goto error;
}
xd3_swap_whole_state (& merge_stream->whole_target,
& merge_input.whole_target);
ret = 0;
error:
xd3_free_stream (& merge_input);
return ret;
}
|
CWE-119
| null | 517,040 |
46171017204232659929844443725204977525
| null | null |
other
|
xdelta-devel
|
ef93ff74203e030073b898c05e8b4860b5d09ef2
| 0 |
main_pipe_write (int outfd, uint8_t *exist_buf, usize_t remain)
{
int ret;
if ((ret = xd3_posix_io (outfd, exist_buf, remain,
(xd3_posix_func*) &write, NULL)))
{
return ret;
}
return 0;
}
|
CWE-119
| null | 517,041 |
172197460088285886961992966898838835437
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status acpi_os_wait_command_ready(void)
{
int ret;
ret = acpi_debugger_wait_command_ready();
if (ret < 0)
return AE_ERROR;
return AE_OK;
}
|
CWE-264
| null | 517,053 |
123435783863756658252452595388535245462
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void acpi_unregister_debugger(const struct acpi_debugger_ops *ops)
{
mutex_lock(&acpi_debugger.lock);
if (ops == acpi_debugger.ops) {
acpi_debugger.ops = NULL;
acpi_debugger.owner = NULL;
}
mutex_unlock(&acpi_debugger.lock);
}
|
CWE-264
| null | 517,054 |
109419781622723395415525441652137693642
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
ssize_t acpi_debugger_read_cmd(char *buffer, size_t buffer_length)
{
ssize_t ret;
ssize_t (*func)(char *, size_t);
struct module *owner;
if (!acpi_debugger_initialized)
return -ENODEV;
mutex_lock(&acpi_debugger.lock);
if (!acpi_debugger.ops) {
ret = -ENODEV;
goto err_lock;
}
if (!try_module_get(acpi_debugger.owner)) {
ret = -ENODEV;
goto err_lock;
}
func = acpi_debugger.ops->read_cmd;
owner = acpi_debugger.owner;
mutex_unlock(&acpi_debugger.lock);
ret = func(buffer, buffer_length);
mutex_lock(&acpi_debugger.lock);
module_put(owner);
err_lock:
mutex_unlock(&acpi_debugger.lock);
return ret;
}
|
CWE-264
| null | 517,055 |
266992266098876145003269217086201381866
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void acpi_os_drop_map_ref(struct acpi_ioremap *map)
{
if (!--map->refcount)
list_del_rcu(&map->list);
}
|
CWE-264
| null | 517,056 |
179775100557510148176577550601129815533
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void acpi_hotplug_work_fn(struct work_struct *work)
{
struct acpi_hp_work *hpw = container_of(work, struct acpi_hp_work, work);
acpi_os_wait_events_complete();
acpi_device_hotplug(hpw->adev, hpw->src);
kfree(hpw);
}
|
CWE-264
| null | 517,057 |
34511092592223219132604430707698630615
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_write_memory(acpi_physical_address phys_addr, u64 value, u32 width)
{
void __iomem *virt_addr;
unsigned int size = width / 8;
bool unmap = false;
rcu_read_lock();
virt_addr = acpi_map_vaddr_lookup(phys_addr, size);
if (!virt_addr) {
rcu_read_unlock();
virt_addr = acpi_os_ioremap(phys_addr, size);
if (!virt_addr)
return AE_BAD_ADDRESS;
unmap = true;
}
switch (width) {
case 8:
writeb(value, virt_addr);
break;
case 16:
writew(value, virt_addr);
break;
case 32:
writel(value, virt_addr);
break;
case 64:
writeq(value, virt_addr);
break;
default:
BUG();
}
if (unmap)
iounmap(virt_addr);
else
rcu_read_unlock();
return AE_OK;
}
|
CWE-264
| null | 517,058 |
335239906833352634137422869511659754021
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
int __init acpi_debugger_init(void)
{
mutex_init(&acpi_debugger.lock);
acpi_debugger_initialized = true;
return 0;
}
|
CWE-264
| null | 517,059 |
106277221044272042625018658365342922413
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status acpi_os_read_port(acpi_io_address port, u32 * value, u32 width)
{
u32 dummy;
if (!value)
value = &dummy;
*value = 0;
if (width <= 8) {
*(u8 *) value = inb(port);
} else if (width <= 16) {
*(u16 *) value = inw(port);
} else if (width <= 32) {
*(u32 *) value = inl(port);
} else {
BUG();
}
return AE_OK;
}
|
CWE-264
| null | 517,060 |
287515157713093420417317555917365247144
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_map_iomem(acpi_physical_address phys, acpi_size size)
{
struct acpi_ioremap *map;
void __iomem *virt;
acpi_physical_address pg_off;
acpi_size pg_sz;
if (phys > ULONG_MAX) {
printk(KERN_ERR PREFIX "Cannot map memory that high\n");
return NULL;
}
if (!acpi_gbl_permanent_mmap)
return __acpi_map_table((unsigned long)phys, size);
mutex_lock(&acpi_ioremap_lock);
/* Check if there's a suitable mapping already. */
map = acpi_map_lookup(phys, size);
if (map) {
map->refcount++;
goto out;
}
map = kzalloc(sizeof(*map), GFP_KERNEL);
if (!map) {
mutex_unlock(&acpi_ioremap_lock);
return NULL;
}
pg_off = round_down(phys, PAGE_SIZE);
pg_sz = round_up(phys + size, PAGE_SIZE) - pg_off;
virt = acpi_map(pg_off, pg_sz);
if (!virt) {
mutex_unlock(&acpi_ioremap_lock);
kfree(map);
return NULL;
}
INIT_LIST_HEAD(&map->list);
map->virt = virt;
map->phys = pg_off;
map->size = pg_sz;
map->refcount = 1;
list_add_tail_rcu(&map->list, &acpi_ioremaps);
out:
mutex_unlock(&acpi_ioremap_lock);
return map->virt + (phys - map->phys);
}
|
CWE-264
| null | 517,061 |
44495674369997469443634638070182387879
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static int __init acpi_os_name_setup(char *str)
{
char *p = acpi_os_name;
int count = ACPI_MAX_OVERRIDE_LEN - 1;
if (!str || !*str)
return 0;
for (; count-- && *str; str++) {
if (isalnum(*str) || *str == ' ' || *str == ':')
*p++ = *str;
else if (*str == '\'' || *str == '"')
continue;
else
break;
}
*p = 0;
return 1;
}
|
CWE-264
| null | 517,062 |
143549337169778356716926688899598258912
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
int acpi_debugger_wait_command_ready(void)
{
int ret;
int (*func)(bool, char *, size_t);
struct module *owner;
if (!acpi_debugger_initialized)
return -ENODEV;
mutex_lock(&acpi_debugger.lock);
if (!acpi_debugger.ops) {
ret = -ENODEV;
goto err_lock;
}
if (!try_module_get(acpi_debugger.owner)) {
ret = -ENODEV;
goto err_lock;
}
func = acpi_debugger.ops->wait_command_ready;
owner = acpi_debugger.owner;
mutex_unlock(&acpi_debugger.lock);
ret = func(acpi_gbl_method_executing,
acpi_gbl_db_line_buf, ACPI_DB_LINE_BUFFER_SIZE);
mutex_lock(&acpi_debugger.lock);
module_put(owner);
err_lock:
mutex_unlock(&acpi_debugger.lock);
return ret;
}
|
CWE-264
| null | 517,063 |
77461188709189766185333219804843510692
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_install_interrupt_handler(u32 gsi, acpi_osd_handler handler,
void *context)
{
unsigned int irq;
acpi_irq_stats_init();
/*
* ACPI interrupts different from the SCI in our copy of the FADT are
* not supported.
*/
if (gsi != acpi_gbl_FADT.sci_interrupt)
return AE_BAD_PARAMETER;
if (acpi_irq_handler)
return AE_ALREADY_ACQUIRED;
if (acpi_gsi_to_irq(gsi, &irq) < 0) {
printk(KERN_ERR PREFIX "SCI (ACPI GSI %d) not registered\n",
gsi);
return AE_OK;
}
acpi_irq_handler = handler;
acpi_irq_context = context;
if (request_irq(irq, acpi_irq, IRQF_SHARED, "acpi", acpi_irq)) {
printk(KERN_ERR PREFIX "SCI (IRQ%d) allocation failed\n", irq);
acpi_irq_handler = NULL;
return AE_NOT_ACQUIRED;
}
acpi_sci_irq = irq;
return AE_OK;
}
|
CWE-264
| null | 517,064 |
265275205189764737118582073625188120626
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static int __init acpi_enforce_resources_setup(char *str)
{
if (str == NULL || *str == '\0')
return 0;
if (!strcmp("strict", str))
acpi_enforce_resources = ENFORCE_RESOURCES_STRICT;
else if (!strcmp("lax", str))
acpi_enforce_resources = ENFORCE_RESOURCES_LAX;
else if (!strcmp("no", str))
acpi_enforce_resources = ENFORCE_RESOURCES_NO;
return 1;
}
|
CWE-264
| null | 517,065 |
71585101765897759163156202824443123126
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status __init acpi_os_initialize(void)
{
acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1a_event_block);
acpi_os_map_generic_address(&acpi_gbl_FADT.xpm1b_event_block);
acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe0_block);
acpi_os_map_generic_address(&acpi_gbl_FADT.xgpe1_block);
if (acpi_gbl_FADT.flags & ACPI_FADT_RESET_REGISTER) {
/*
* Use acpi_os_map_generic_address to pre-map the reset
* register if it's in system memory.
*/
int rv;
rv = acpi_os_map_generic_address(&acpi_gbl_FADT.reset_register);
pr_debug(PREFIX "%s: map reset_reg status %d\n", __func__, rv);
}
acpi_os_initialized = true;
return AE_OK;
}
|
CWE-264
| null | 517,066 |
157228226694312647974195617617602844870
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_get_physical_address(void *virt, acpi_physical_address * phys)
{
if (!phys || !virt)
return AE_BAD_PARAMETER;
*phys = virt_to_phys(virt);
return AE_OK;
}
|
CWE-264
| null | 517,067 |
289449125261138902073851723469521133098
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_physical_address __init acpi_os_get_root_pointer(void)
{
#ifdef CONFIG_KEXEC
if (acpi_rsdp && (get_securelevel() <= 0))
return acpi_rsdp;
#endif
if (efi_enabled(EFI_CONFIG_TABLES)) {
if (efi.acpi20 != EFI_INVALID_TABLE_ADDR)
return efi.acpi20;
else if (efi.acpi != EFI_INVALID_TABLE_ADDR)
return efi.acpi;
else {
printk(KERN_ERR PREFIX
"System description tables not found\n");
return 0;
}
} else if (IS_ENABLED(CONFIG_ACPI_LEGACY_TABLES_LOOKUP)) {
acpi_physical_address pa = 0;
acpi_find_root_pointer(&pa);
return pa;
}
return 0;
}
|
CWE-264
| null | 517,068 |
226488002692608316363110036767601985357
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void __init set_osi_linux(unsigned int enable)
{
if (osi_linux.enable != enable)
osi_linux.enable = enable;
if (osi_linux.enable)
acpi_osi_setup("Linux");
else
acpi_osi_setup("!Linux");
return;
}
|
CWE-264
| null | 517,069 |
53211982068596837830828617365042082600
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_create_cache(char *name, u16 size, u16 depth, acpi_cache_t ** cache)
{
*cache = kmem_cache_create(name, size, 0, 0, NULL);
if (*cache == NULL)
return AE_ERROR;
else
return AE_OK;
}
|
CWE-264
| null | 517,070 |
98095169472745365672065697053256262427
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_map_memory(acpi_physical_address phys, acpi_size size)
{
return (void *)acpi_os_map_iomem(phys, size);
}
|
CWE-264
| null | 517,071 |
227482172968938891357769087003168000081
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void __init early_acpi_os_unmap_memory(void __iomem *virt, acpi_size size)
{
if (!acpi_gbl_permanent_mmap)
__acpi_unmap_table(virt, size);
}
|
CWE-264
| null | 517,072 |
184146579039774617650934544763159864974
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status acpi_os_prepare_extended_sleep(u8 sleep_state, u32 val_a,
u32 val_b)
{
int rc = 0;
if (__acpi_os_prepare_extended_sleep)
rc = __acpi_os_prepare_extended_sleep(sleep_state,
val_a, val_b);
if (rc < 0)
return AE_ERROR;
else if (rc > 0)
return AE_CTRL_SKIP;
return AE_OK;
}
|
CWE-264
| null | 517,073 |
239922879110590065833965239344317543950
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status acpi_os_get_line(char *buffer, u32 buffer_length, u32 *bytes_read)
{
#ifdef ENABLE_DEBUGGER
if (acpi_in_debugger) {
u32 chars;
kdb_read(buffer, buffer_length);
/* remove the CR kdb includes */
chars = strlen(buffer) - 1;
buffer[chars] = '\0';
}
#else
int ret;
ret = acpi_debugger_read_cmd(buffer, buffer_length);
if (ret < 0)
return AE_ERROR;
if (bytes_read)
*bytes_read = ret;
#endif
return AE_OK;
}
|
CWE-264
| null | 517,074 |
4250583841666447621852884216193121826
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static u32 acpi_osi_handler(acpi_string interface, u32 supported)
{
if (!strcmp("Linux", interface)) {
printk_once(KERN_NOTICE FW_BUG PREFIX
"BIOS _OSI(Linux) query %s%s\n",
osi_linux.enable ? "honored" : "ignored",
osi_linux.cmdline ? " via cmdline" :
osi_linux.dmi ? " via DMI" : "");
}
if (!strcmp("Darwin", interface)) {
/*
* Apple firmware will behave poorly if it receives positive
* answers to "Darwin" and any other OS. Respond positively
* to Darwin and then disable all other vendor strings.
*/
acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
supported = ACPI_UINT32_MAX;
}
return supported;
}
|
CWE-264
| null | 517,075 |
137412302633312784254538034289273115146
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
{
if (width <= 8) {
outb(value, port);
} else if (width <= 16) {
outw(value, port);
} else if (width <= 32) {
outl(value, port);
} else {
BUG();
}
return AE_OK;
}
|
CWE-264
| null | 517,076 |
99864689838899234612046065981748544550
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_map_lookup_virt(void __iomem *virt, acpi_size size)
{
struct acpi_ioremap *map;
list_for_each_entry_rcu(map, &acpi_ioremaps, list)
if (map->virt <= virt &&
virt + size <= map->virt + map->size)
return map;
return NULL;
}
|
CWE-264
| null | 517,077 |
184919937704963021123259920358825570076
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void acpi_unmap(acpi_physical_address pg_off, void __iomem *vaddr)
{
unsigned long pfn;
pfn = pg_off >> PAGE_SHIFT;
if (should_use_kmap(pfn))
kunmap(pfn_to_page(pfn));
else
iounmap(vaddr);
}
|
CWE-264
| null | 517,078 |
21237591147233612260873591939826091248
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_read_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
u64 *value, u32 width)
{
int result, size;
u32 value32;
if (!value)
return AE_BAD_PARAMETER;
switch (width) {
case 8:
size = 1;
break;
case 16:
size = 2;
break;
case 32:
size = 4;
break;
default:
return AE_ERROR;
}
result = raw_pci_read(pci_id->segment, pci_id->bus,
PCI_DEVFN(pci_id->device, pci_id->function),
reg, size, &value32);
*value = value32;
return (result ? AE_ERROR : AE_OK);
}
|
CWE-264
| null | 517,079 |
29609758990753502529596672888813710947
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void acpi_table_taint(struct acpi_table_header *table)
{
pr_warn(PREFIX
"Override [%4.4s-%8.8s], this is unsafe: tainting kernel\n",
table->signature, table->oem_table_id);
add_taint(TAINT_OVERRIDDEN_ACPI_TABLE, LOCKDEP_NOW_UNRELIABLE);
}
|
CWE-264
| null | 517,080 |
227089899837402112361208508867617191561
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void acpi_os_release_lock(acpi_spinlock lockp, acpi_cpu_flags flags)
{
spin_unlock_irqrestore(lockp, flags);
}
|
CWE-264
| null | 517,081 |
290192900922547636069090056672771665714
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void __init acpi_osi_setup(char *str)
{
struct osi_setup_entry *osi;
bool enable = true;
int i;
if (!acpi_gbl_create_osi_method)
return;
if (str == NULL || *str == '\0') {
printk(KERN_INFO PREFIX "_OSI method disabled\n");
acpi_gbl_create_osi_method = FALSE;
return;
}
if (*str == '!') {
str++;
if (*str == '\0') {
osi_linux.default_disabling = 1;
return;
} else if (*str == '*') {
acpi_update_interfaces(ACPI_DISABLE_ALL_STRINGS);
for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
osi = &osi_setup_entries[i];
osi->enable = false;
}
return;
}
enable = false;
}
for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
osi = &osi_setup_entries[i];
if (!strcmp(osi->string, str)) {
osi->enable = enable;
break;
} else if (osi->string[0] == '\0') {
osi->enable = enable;
strncpy(osi->string, str, OSI_STRING_LENGTH_MAX);
break;
}
}
}
|
CWE-264
| null | 517,082 |
102250923367916430994221528803308744554
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
bool acpi_osi_is_win8(void)
{
return acpi_gbl_osi_data >= ACPI_OSI_WIN_8;
}
|
CWE-264
| null | 517,083 |
237318172306424819143947564185686047541
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static int __init acpi_no_static_ssdt_setup(char *s)
{
acpi_gbl_disable_ssdt_table_install = TRUE;
pr_info("ACPI: static SSDT installation disabled\n");
return 0;
}
|
CWE-264
| null | 517,084 |
43521318005388981130514059264014805979
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void acpi_os_unmap_generic_address(struct acpi_generic_address *gas)
{
u64 addr;
struct acpi_ioremap *map;
if (gas->space_id != ACPI_ADR_SPACE_SYSTEM_MEMORY)
return;
/* Handle possible alignment issues */
memcpy(&addr, &gas->address, sizeof(addr));
if (!addr || !gas->bit_width)
return;
mutex_lock(&acpi_ioremap_lock);
map = acpi_map_lookup(addr, gas->bit_width / 8);
if (!map) {
mutex_unlock(&acpi_ioremap_lock);
return;
}
acpi_os_drop_map_ref(map);
mutex_unlock(&acpi_ioremap_lock);
acpi_os_map_cleanup(map);
}
|
CWE-264
| null | 517,085 |
52343546130756979672526451728087205832
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void acpi_os_stall(u32 us)
{
while (us) {
u32 delay = 1000;
if (delay > us)
delay = us;
udelay(delay);
touch_nmi_watchdog();
us -= delay;
}
}
|
CWE-264
| null | 517,086 |
168465568722393865760727522436412846402
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_write_pci_configuration(struct acpi_pci_id * pci_id, u32 reg,
u64 value, u32 width)
{
int result, size;
switch (width) {
case 8:
size = 1;
break;
case 16:
size = 2;
break;
case 32:
size = 4;
break;
default:
return AE_ERROR;
}
result = raw_pci_write(pci_id->segment, pci_id->bus,
PCI_DEVFN(pci_id->device, pci_id->function),
reg, size, value);
return (result ? AE_ERROR : AE_OK);
}
|
CWE-264
| null | 517,087 |
245080937381648760925405831066888803982
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static int __init acpi_no_auto_serialize_setup(char *str)
{
acpi_gbl_auto_serialize_methods = FALSE;
pr_info("ACPI: auto-serialization disabled\n");
return 1;
}
|
CWE-264
| null | 517,088 |
149077320078155676568706240385025310806
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void acpi_os_sleep(u64 ms)
{
msleep(ms);
}
|
CWE-264
| null | 517,089 |
274980658601599386139793611110405416260
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void acpi_os_wait_events_complete(void)
{
/*
* Make sure the GPE handler or the fixed event handler is not used
* on another CPU after removal.
*/
if (acpi_sci_irq_valid())
synchronize_hardirq(acpi_sci_irq);
flush_workqueue(kacpid_wq);
flush_workqueue(kacpi_notify_wq);
}
|
CWE-264
| null | 517,090 |
56471683948738537772257934189517556937
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static irqreturn_t acpi_irq(int irq, void *dev_id)
{
u32 handled;
handled = (*acpi_irq_handler) (acpi_irq_context);
if (handled) {
acpi_irq_handled++;
return IRQ_HANDLED;
} else {
acpi_irq_not_handled++;
return IRQ_NONE;
}
}
|
CWE-264
| null | 517,091 |
74313718240288653805836062898141883374
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
int acpi_resources_are_enforced(void)
{
return acpi_enforce_resources == ENFORCE_RESOURCES_STRICT;
}
|
CWE-264
| null | 517,092 |
324494258923373894094222806222703798709
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_create_semaphore(u32 max_units, u32 initial_units, acpi_handle * handle)
{
struct semaphore *sem = NULL;
sem = acpi_os_allocate_zeroed(sizeof(struct semaphore));
if (!sem)
return AE_NO_MEMORY;
sema_init(sem, initial_units);
*handle = (acpi_handle *) sem;
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Creating semaphore[%p|%d].\n",
*handle, initial_units));
return AE_OK;
}
|
CWE-264
| null | 517,093 |
287210349932677131599045427987872669833
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
int acpi_check_region(resource_size_t start, resource_size_t n,
const char *name)
{
struct resource res = {
.start = start,
.end = start + n - 1,
.name = name,
.flags = IORESOURCE_IO,
};
return acpi_check_resource_conflict(&res);
}
|
CWE-264
| null | 517,094 |
268179324830389999552715130238298260005
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_predefined_override(const struct acpi_predefined_names *init_val,
char **new_val)
{
if (!init_val || !new_val)
return AE_BAD_PARAMETER;
*new_val = NULL;
if (!memcmp(init_val->name, "_OS_", 4) && strlen(acpi_os_name)) {
printk(KERN_INFO PREFIX "Overriding _OS definition to '%s'\n",
acpi_os_name);
*new_val = acpi_os_name;
}
if (!memcmp(init_val->name, "_REV", 4) && acpi_rev_override) {
printk(KERN_INFO PREFIX "Overriding _REV return value to 5\n");
*new_val = (char *)5;
}
return AE_OK;
}
|
CWE-264
| null | 517,095 |
163166241511957034398712495717620716963
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void __init acpi_osi_setup_late(void)
{
struct osi_setup_entry *osi;
char *str;
int i;
acpi_status status;
if (osi_linux.default_disabling) {
status = acpi_update_interfaces(ACPI_DISABLE_ALL_VENDOR_STRINGS);
if (ACPI_SUCCESS(status))
printk(KERN_INFO PREFIX "Disabled all _OSI OS vendors\n");
}
for (i = 0; i < OSI_STRING_ENTRIES_MAX; i++) {
osi = &osi_setup_entries[i];
str = osi->string;
if (*str == '\0')
break;
if (osi->enable) {
status = acpi_install_interface(str);
if (ACPI_SUCCESS(status))
printk(KERN_INFO PREFIX "Added _OSI(%s)\n", str);
} else {
status = acpi_remove_interface(str);
if (ACPI_SUCCESS(status))
printk(KERN_INFO PREFIX "Deleted _OSI(%s)\n", str);
}
}
}
|
CWE-264
| null | 517,096 |
47371001712022544457879783598812900063
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status acpi_os_delete_semaphore(acpi_handle handle)
{
struct semaphore *sem = (struct semaphore *)handle;
if (!sem)
return AE_BAD_PARAMETER;
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Deleting semaphore[%p].\n", handle));
BUG_ON(!list_empty(&sem->wait_list));
kfree(sem);
sem = NULL;
return AE_OK;
}
|
CWE-264
| null | 517,097 |
179113053541306524293588879615744556275
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
void __init acpi_initrd_initialize_tables(void)
{
int table_offset = 0;
int table_index = 0;
u32 table_length;
struct acpi_table_header *table;
if (!acpi_tables_addr)
return;
while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) {
table = acpi_os_map_memory(acpi_tables_addr + table_offset,
ACPI_HEADER_SIZE);
if (table_offset + table->length > all_tables_size) {
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
WARN_ON(1);
return;
}
table_length = table->length;
/* Skip RSDT/XSDT which should only be used for override */
if (test_bit(table_index, acpi_initrd_installed) ||
ACPI_COMPARE_NAME(table->signature, ACPI_SIG_RSDT) ||
ACPI_COMPARE_NAME(table->signature, ACPI_SIG_XSDT)) {
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
goto next_table;
}
acpi_table_taint(table);
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
acpi_install_table(acpi_tables_addr + table_offset, TRUE);
set_bit(table_index, acpi_initrd_installed);
next_table:
table_offset += table_length;
table_index++;
}
}
|
CWE-264
| null | 517,098 |
336744447211563350176634462634137439662
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
int __init acpi_rev_override_setup(char *str)
{
acpi_rev_override = true;
return 1;
}
|
CWE-264
| null | 517,099 |
238937978848374281395562692517308662154
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void acpi_os_map_cleanup(struct acpi_ioremap *map)
{
if (!map->refcount) {
synchronize_rcu_expedited();
acpi_unmap(map->phys, map->virt);
kfree(map);
}
}
|
CWE-264
| null | 517,100 |
37573510218939660495455222055925501875
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_physical_table_override(struct acpi_table_header *existing_table,
acpi_physical_address *address,
u32 *table_length)
{
*table_length = 0;
*address = 0;
return AE_OK;
}
|
CWE-264
| null | 517,101 |
201635991112643867269820029356614183029
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static int __init acpi_disable_return_repair(char *s)
{
printk(KERN_NOTICE PREFIX
"ACPI: Predefined validation mechanism disabled\n");
acpi_gbl_disable_auto_repair = TRUE;
return 1;
}
|
CWE-264
| null | 517,102 |
303555110289228821665644497653281995723
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static u8 __init acpi_table_checksum(u8 *buffer, u32 length)
{
u8 sum = 0;
u8 *end = buffer + length;
while (buffer < end)
sum = (u8) (sum + *(buffer++));
return sum;
}
|
CWE-264
| null | 517,103 |
292250836200291402396338682104167685568
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_status acpi_os_signal_semaphore(acpi_handle handle, u32 units)
{
struct semaphore *sem = (struct semaphore *)handle;
if (!acpi_os_initialized)
return AE_OK;
if (!sem || (units < 1))
return AE_BAD_PARAMETER;
if (units > 1)
return AE_SUPPORT;
ACPI_DEBUG_PRINT((ACPI_DB_MUTEX, "Signaling semaphore[%p|%d]\n", handle,
units));
up(sem);
return AE_OK;
}
|
CWE-264
| null | 517,104 |
243305287964474931211612965208982073902
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_map_vaddr_lookup(acpi_physical_address phys, unsigned int size)
{
struct acpi_ioremap *map;
map = acpi_map_lookup(phys, size);
if (map)
return map->virt + (phys - map->phys);
return NULL;
}
|
CWE-264
| null | 517,105 |
272160139743082718617628623796723331611
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
static void __init acpi_cmdline_osi_linux(unsigned int enable)
{
osi_linux.cmdline = 1; /* cmdline set the default and override DMI */
osi_linux.dmi = 0;
set_osi_linux(enable);
return;
}
|
CWE-264
| null | 517,106 |
198652805379616395833807664470853504125
| null | null |
other
|
mjg59_linux
|
a4a5ed2835e8ea042868b7401dced3f517cafa76
| 0 |
acpi_os_physical_table_override(struct acpi_table_header *existing_table,
acpi_physical_address *address, u32 *length)
{
int table_offset = 0;
int table_index = 0;
struct acpi_table_header *table;
u32 table_length;
*length = 0;
*address = 0;
if (!acpi_tables_addr)
return AE_OK;
while (table_offset + ACPI_HEADER_SIZE <= all_tables_size) {
table = acpi_os_map_memory(acpi_tables_addr + table_offset,
ACPI_HEADER_SIZE);
if (table_offset + table->length > all_tables_size) {
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
WARN_ON(1);
return AE_OK;
}
table_length = table->length;
/* Only override tables matched */
if (test_bit(table_index, acpi_initrd_installed) ||
memcmp(existing_table->signature, table->signature, 4) ||
memcmp(table->oem_table_id, existing_table->oem_table_id,
ACPI_OEM_TABLE_ID_SIZE)) {
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
goto next_table;
}
*length = table_length;
*address = acpi_tables_addr + table_offset;
acpi_table_taint(existing_table);
acpi_os_unmap_memory(table, ACPI_HEADER_SIZE);
set_bit(table_index, acpi_initrd_installed);
break;
next_table:
table_offset += table_length;
table_index++;
}
return AE_OK;
}
|
CWE-264
| null | 517,107 |
256272886065553857513179065105907046357
| null | null |
other
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.