libarchive-3.7.2-3.fc41

List of Defects

Error: GCC_ANALYZER_WARNING (CWE-688): [#def1]
libarchive-3.7.2/cpio/cpio.c: scope_hint: In function ‘mode_pass’
libarchive-3.7.2/cpio/cpio.c:1242:9: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘*cpio.destdir’ where non-null expected
<built-in>: note: argument 1 of ‘__builtin_memcpy’ must be non-null
# 1240|   	cpio->destdir_len = strlen(destdir);
# 1241|   	cpio->destdir = malloc(cpio->destdir_len + 8);
# 1242|-> 	memcpy(cpio->destdir, destdir, cpio->destdir_len);
# 1243|   	if (cpio->destdir_len == 0 || destdir[cpio->destdir_len - 1] != '/')
# 1244|   		cpio->destdir[cpio->destdir_len++] = '/';

Error: CLANG_WARNING: [#def2]
libarchive-3.7.2/libarchive/archive_acl.c:1213:8: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 's')
# 1211|   			s = field[0].start;
# 1212|   			len = field[0].end - field[0].start;
# 1213|-> 			if (*s == L'd' && (len == 1 || (len >= 7
# 1214|   			    && wmemcmp((s + 1), L"efault", 6) == 0))) {
# 1215|   				type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;

Error: CLANG_WARNING: [#def3]
libarchive-3.7.2/libarchive/archive_acl.c:1696:8: warning[core.NullDereference]: Dereference of null pointer (loaded from variable 's')
# 1694|   			s = field[0].start;
# 1695|   			len = field[0].end - field[0].start;
# 1696|-> 			if (*s == 'd' && (len == 1 || (len >= 7
# 1697|   			    && memcmp((s + 1), "efault", 6) == 0))) {
# 1698|   				type = ARCHIVE_ENTRY_ACL_TYPE_DEFAULT;

Error: CPPCHECK_WARNING (CWE-457): [#def4]
libarchive-3.7.2/libarchive/archive_blake2s_ref.c:89: warning[uninitvar]: Uninitialized variable: P->digest_length
#   87|       S->h[i] ^= load32( &p[i * 4] );
#   88|   
#   89|->   S->outlen = P->digest_length;
#   90|     return 0;
#   91|   }

Error: CPPCHECK_WARNING (CWE-457): [#def5]
libarchive-3.7.2/libarchive/archive_blake2sp_ref.c:41: warning[uninitvar]: Uninitialized variable: P->inner_length
#   39|   {
#   40|     int err = blake2s_init_param(S, P);
#   41|->   S->outlen = P->inner_length;
#   42|     return err;
#   43|   }

Error: CPPCHECK_WARNING (CWE-401): [#def6]
libarchive-3.7.2/libarchive/archive_match.c:237: error[memleak]: Memory leak: a
#  235|   	match_list_init(&(a->inclusion_gnames));
#  236|   	time(&a->now);
#  237|-> 	return (&(a->archive));
#  238|   }
#  239|   

Error: CLANG_WARNING: [#def7]
libarchive-3.7.2/libarchive/archive_match.c:608:2: warning[deadcode.DeadStores]: Value stored to 'r' is never read
#  606|   		return (ARCHIVE_FATAL);
#  607|   	}
#  608|-> 	r = archive_read_support_format_raw(ar);
#  609|   	r = archive_read_support_format_empty(ar);
#  610|   	if (r != ARCHIVE_OK) {

Error: CLANG_WARNING: [#def8]
libarchive-3.7.2/libarchive/archive_ppmd8.c:692:5: warning[core.CallAndMessage]: 1st function call argument is an uninitialized value
#  690|       *ONE_STATE(c1) = upState;
#  691|       c1->Suffix = REF(c);
#  692|->     SetSuccessor(ps[--numPs], REF(c1));
#  693|       c = c1;
#  694|     }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def9]
libarchive-3.7.2/libarchive/archive_rb.c: scope_hint: In function '__archive_rb_tree_swap_prune_and_rebalance'
libarchive-3.7.2/libarchive/archive_rb.c:63:11: warning[-Wanalyzer-null-dereference]: dereference of NULL 'standin'
libarchive-3.7.2/libarchive/archive_rb.c:374:44: note: in expansion of macro 'RB_POSITION'
libarchive-3.7.2/libarchive/archive_rb.c:53:35: note: in definition of macro 'RB_SENTINEL_P'
libarchive-3.7.2/libarchive/archive_rb.c:54:53: note: in expansion of macro 'rb_left'
libarchive-3.7.2/libarchive/archive_rb.c:58:28: note: in expansion of macro 'RB_LEFT_SENTINEL_P'
libarchive-3.7.2/libarchive/archive_rb.c:515:13: note: in expansion of macro 'RB_CHILDLESS_P'
libarchive-3.7.2/libarchive/archive_rb.c:520:14: note: in expansion of macro 'RB_TWOCHILDREN_P'
libarchive-3.7.2/libarchive/archive_rb.c:538:17: note: in expansion of macro 'RB_POSITION'
libarchive-3.7.2/libarchive/archive_rb.c:53:35: note: in definition of macro 'RB_SENTINEL_P'
libarchive-3.7.2/libarchive/archive_rb.c:374:44: note: in expansion of macro 'RB_POSITION'
#   61|   
#   62|   #define	RB_POSITION(rb)	\
#   63|->     (((rb)->rb_info & RB_FLAG_POSITION) ? RB_DIR_RIGHT : RB_DIR_LEFT)
#   64|   #define	RB_RIGHT_P(rb)		(RB_POSITION(rb) == RB_DIR_RIGHT)
#   65|   #define	RB_LEFT_P(rb)		(RB_POSITION(rb) == RB_DIR_LEFT)

Error: CPPCHECK_WARNING (CWE-401): [#def10]
libarchive-3.7.2/libarchive/archive_read_add_passphrase.c:84: error[memleak]: Memory leak: p.passphrase
#   82|   		return (NULL);
#   83|   	}
#   84|-> 	return (p);
#   85|   }
#   86|   

Error: CLANG_WARNING: [#def11]
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:743:5: warning[deadcode.DeadStores]: Value stored to 'flags' is never read
#  741|   				t->restore_time.noatime = 1;
#  742|   			else if (errno == EPERM)
#  743|-> 				flags &= ~O_NOATIME;
#  744|   		}
#  745|   #endif

Error: GCC_ANALYZER_WARNING (CWE-401): [#def12]
libarchive-3.7.2/libarchive/archive_read_disk_posix.c: scope_hint: In function 'setup_sparse'
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:1208:20: warning[-Wanalyzer-malloc-leak]: leak of '*t.sparse_list'
# 1206|   		t->sparse_list = malloc(sizeof(t->sparse_list[0]) *
# 1207|   		    t->sparse_list_size);
# 1208|-> 		if (t->sparse_list == NULL) {
# 1209|   			t->sparse_list_size = 0;
# 1210|   			archive_set_error(&a->archive, ENOMEM,

Error: GCC_ANALYZER_WARNING (CWE-775): [#def13]
libarchive-3.7.2/libarchive/archive_read_disk_posix.c: scope_hint: In function 'tree_reopen'
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:2238:12: warning[-Wanalyzer-fd-leak]: leak of file descriptor '*t.initial_dir_fd'
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:98: included_from: Included from here.
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:1323:9: note: in expansion of macro 'archive_check_magic'
# 2236|   	 * unhelpful and unnecessary errors later.
# 2237|   	 */
# 2238|-> 	if (t->initial_dir_fd < 0)
# 2239|   		t->initial_dir_fd = open(".", o_flag | O_CLOEXEC);
# 2240|   #endif

Error: GCC_ANALYZER_WARNING (CWE-775): [#def14]
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:2239:35: warning[-Wanalyzer-fd-leak]: leak of file descriptor '*t.initial_dir_fd'
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:1323:9: note: in expansion of macro 'archive_check_magic'
# 2237|   	 */
# 2238|   	if (t->initial_dir_fd < 0)
# 2239|-> 		t->initial_dir_fd = open(".", o_flag | O_CLOEXEC);
# 2240|   #endif
# 2241|   	__archive_ensure_cloexec_flag(t->initial_dir_fd);

Error: CLANG_WARNING: [#def15]
libarchive-3.7.2/libarchive/archive_read_disk_posix.c:2374:13: warning[core.NullDereference]: Access to field 'next' results in a dereference of a null pointer (loaded from variable 'te')
# 2372|   		t->current = t->current->parent;
# 2373|   	te = t->stack;
# 2374|-> 	t->stack = te->next;
# 2375|   	t->dirname_length = te->dirname_length;
# 2376|   	t->basename = t->path.s + t->dirname_length;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def16]
libarchive-3.7.2/libarchive/archive_read_support_filter_gzip.c: scope_hint: In function 'peek_at_header'
libarchive-3.7.2/libarchive/archive_read_support_filter_gzip.c:197:37: warning[-Wanalyzer-malloc-leak]: leak of 'strdup(p + (sizetype)len)'
#  195|   			/* Reset the name in case of repeat header reads. */
#  196|   			free(state->name);
#  197|-> 			state->name = strdup((const char *)&p[file_start]);
#  198|   		}
#  199|   #endif

Error: GCC_ANALYZER_WARNING (CWE-401): [#def17]
libarchive-3.7.2/libarchive/archive_read_support_filter_lz4.c: scope_hint: In function 'lz4_allocate_out_block'
libarchive-3.7.2/libarchive/archive_read_support_filter_lz4.c:262:12: warning[-Wanalyzer-malloc-leak]: leak of 'out_block'
#  260|   		state->out_block = out_block;
#  261|   	}
#  262|-> 	if (!state->flags.block_independence)
#  263|   		memset(state->out_block, 0, 64 * 1024);
#  264|   	return (ARCHIVE_OK);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def18]
libarchive-3.7.2/libarchive/archive_read_support_filter_lz4.c:263:17: warning[-Wanalyzer-malloc-leak]: leak of 'out_block'
#  261|   	}
#  262|   	if (!state->flags.block_independence)
#  263|-> 		memset(state->out_block, 0, 64 * 1024);
#  264|   	return (ARCHIVE_OK);
#  265|   }

Error: GCC_ANALYZER_WARNING (CWE-688): [#def19]
libarchive-3.7.2/libarchive/archive_read_support_filter_program.c: scope_hint: In function 'archive_read_support_filter_program_signature'
libarchive-3.7.2/libarchive/archive_read_support_filter_program.c:153:17: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'malloc(signature_len)' where non-null expected
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
#  151|   		state->signature_len = signature_len;
#  152|   		state->signature = malloc(signature_len);
#  153|-> 		memcpy(state->signature, signature, signature_len);
#  154|   	}
#  155|   

Error: GCC_ANALYZER_WARNING (CWE-835): [#def20]
libarchive-3.7.2/libarchive/archive_read_support_filter_uu.c: scope_hint: In function 'get_line'
libarchive-3.7.2/libarchive/archive_read_support_filter_uu.c:182:20: warning[-Wanalyzer-infinite-loop]: infinite loop
#  180|   
#  181|   	len = 0;
#  182|-> 	while (len < avail) {
#  183|   		switch (ascii[*b]) {
#  184|   		case 0:	/* Non-ascii character or control character. */

Error: GCC_ANALYZER_WARNING (CWE-401): [#def21]
libarchive-3.7.2/libarchive/archive_read_support_filter_uu.c: scope_hint: In function 'ensure_in_buff_size'
libarchive-3.7.2/libarchive/archive_read_support_filter_uu.c:437:40: warning[-Wanalyzer-malloc-leak]: leak of 'ptr'
#  435|   		free(uudecode->in_buff);
#  436|   		uudecode->in_buff = ptr;
#  437|-> 		uudecode->in_allocated = newsize;
#  438|   	}
#  439|   	return (ARCHIVE_OK);

Error: CLANG_WARNING: [#def22]
libarchive-3.7.2/libarchive/archive_read_support_filter_uu.c:495:3: warning[core.NonNullParamChecker]: Null pointer passed to 2nd parameter expecting 'nonnull'
#  493|   		    avail_in + uudecode->in_cnt) != ARCHIVE_OK)
#  494|   			return (ARCHIVE_FATAL);
#  495|-> 		memcpy(uudecode->in_buff + uudecode->in_cnt,
#  496|   		    d, avail_in);
#  497|   		d = uudecode->in_buff;

Error: CLANG_WARNING: [#def23]
libarchive-3.7.2/libarchive/archive_read_support_format_7zip.c:829:4: warning[core.NonNullParamChecker]: Null pointer passed to 2nd parameter expecting 'nonnull'
#  827|   			}
#  828|   			symname = mem;
#  829|-> 			memcpy(symname+symsize, buff, size);
#  830|   			symsize += size;
#  831|   		}

Error: CLANG_WARNING: [#def24]
libarchive-3.7.2/libarchive/archive_read_support_format_7zip.c:2620:9: warning[deadcode.DeadStores]: Although the value stored to 'p' is used in the enclosing expression, the value is never actually read from 'p'
# 2618|   
# 2619|   			/* Skip one byte. */
# 2620|-> 			if ((p = header_bytes(a, 1)) == NULL)
# 2621|   				return (-1);
# 2622|   			ll--;

Error: CLANG_WARNING: [#def25]
libarchive-3.7.2/libarchive/archive_read_support_format_iso9660.c:3054:16: warning[core.NullDereference]: Access to field 'key' results in a dereference of an undefined pointer value
# 3052|   	while (hole > 0) {
# 3053|   		parent = (hole - 1)/2;
# 3054|-> 		parent_key = heap->files[parent]->key;
# 3055|   		if (file_key >= parent_key) {
# 3056|   			heap->files[hole] = file;

Error: CPPCHECK_WARNING (CWE-758): [#def26]
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c:699: warning[objectIndex]: The address of local variable 'window' might be accessed at non-zero index.
#  697|       else {
#  698|         for (li = 0; li < l; li++)
#  699|->         d[li] = s[li];
#  700|       }
#  701|       remaining -= l;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def27]
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c: scope_hint: In function 'read_header'
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c:1683:3: warning[-Wanalyzer-null-argument]: use of NULL where non-null expected
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c:3771:8: note: in expansion of macro 'rar_br_read_ahead'
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c:3771:8: note: in expansion of macro 'rar_br_read_ahead'
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c: scope_hint: In function 'read_header'
<built-in>: note: argument 1 of '__builtin_memcpy' must be non-null
# 1681|     rar->filename_save = (char*)realloc(rar->filename_save,
# 1682|                                         filename_size + 1);
# 1683|->   memcpy(rar->filename_save, rar->filename, filename_size + 1);
# 1684|     rar->filename_save_size = filename_size;
# 1685|   

Error: CLANG_WARNING: [#def28]
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c:3210:12: warning[core.NullDereference]: Access to field 'next' results in a dereference of a null pointer (loaded from variable 'prog')
# 3208|     prog = filters->progs;
# 3209|     for (i = 0; i < num; i++)
# 3210|->     prog = prog->next;
# 3211|     if (prog)
# 3212|       prog->usagecount++;

Error: CPPCHECK_WARNING (CWE-401): [#def29]
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c:3315: error[memleak]: Memory leak: filter
# 3313|     filter->globaldata = calloc(1, filter->globaldatalen);
# 3314|     if (!filter->globaldata)
# 3315|->     return NULL;
# 3316|     if (globaldata)
# 3317|       memcpy(filter->globaldata, globaldata, globaldatalen);

Error: CLANG_WARNING: [#def30]
libarchive-3.7.2/libarchive/archive_read_support_format_rar.c:3315:12: warning[unix.Malloc]: Potential leak of memory pointed to by 'filter'
# 3313|     filter->globaldata = calloc(1, filter->globaldatalen);
# 3314|     if (!filter->globaldata)
# 3315|->     return NULL;
# 3316|     if (globaldata)
# 3317|       memcpy(filter->globaldata, globaldata, globaldatalen);

Error: CLANG_WARNING: [#def31]
libarchive-3.7.2/libarchive/archive_read_support_format_rar5.c:391:11: warning[unix.MallocSizeof]: Result of 'malloc' is converted to a pointer of type 'size_t', which is incompatible with sizeof operand type 'void *'
#  389|   
#  390|   	cdeque_clear(d);
#  391|-> 	d->arr = malloc(sizeof(void*) * max_capacity_power_of_2);
#  392|   
#  393|   	return d->arr ? CDE_OK : CDE_ALLOC;

Error: CLANG_WARNING: [#def32]
libarchive-3.7.2/libarchive/archive_read_support_format_rar5.c:2951:9: warning[unix.Malloc]: Potential leak of memory pointed to by 'filt'
# 2949|   	}
# 2950|   
# 2951|-> 	return ARCHIVE_OK;
# 2952|   }
# 2953|   

Error: GCC_ANALYZER_WARNING (CWE-465): [#def33]
libarchive-3.7.2/libarchive/archive_string.c: scope_hint: In function 'archive_string_append'
libarchive-3.7.2/libarchive/archive_string.c:206:12: warning[-Wanalyzer-deref-before-check]: check of 'as' for NULL after already dereferencing it
#  204|   archive_string_append(struct archive_string *as, const char *p, size_t s)
#  205|   {
#  206|-> 	if (archive_string_ensure(as, as->length + s + 1) == NULL)
#  207|   		return (NULL);
#  208|   	if (s)

Error: GCC_ANALYZER_WARNING (CWE-415): [#def34]
libarchive-3.7.2/libarchive/archive_util.c: scope_hint: In function 'archive_utility_string_sort_helper'
libarchive-3.7.2/libarchive/archive_util.c:654:40: warning[-Wanalyzer-double-free]: double-'free' of 'lesser'
#  652|   		{
#  653|   			lesser_count++;
#  654|-> 			tmp = (char **)realloc(lesser,
#  655|   				lesser_count * sizeof(char *));
#  656|   			if (!tmp) {

Error: GCC_ANALYZER_WARNING (CWE-415): [#def35]
libarchive-3.7.2/libarchive/archive_util.c:657:33: warning[-Wanalyzer-double-free]: double-'free' of 'greater'
#  655|   				lesser_count * sizeof(char *));
#  656|   			if (!tmp) {
#  657|-> 				free(greater);
#  658|   				free(lesser);
#  659|   				return (ARCHIVE_FATAL);

Error: GCC_ANALYZER_WARNING (CWE-415): [#def36]
libarchive-3.7.2/libarchive/archive_util.c:667:40: warning[-Wanalyzer-double-free]: double-'free' of 'greater'
#  665|   		{
#  666|   			greater_count++;
#  667|-> 			tmp = (char **)realloc(greater,
#  668|   				greater_count * sizeof(char *));
#  669|   			if (!tmp) {

Error: GCC_ANALYZER_WARNING (CWE-415): [#def37]
libarchive-3.7.2/libarchive/archive_util.c:671:33: warning[-Wanalyzer-double-free]: double-'free' of 'lesser'
#  669|   			if (!tmp) {
#  670|   				free(greater);
#  671|-> 				free(lesser);
#  672|   				return (ARCHIVE_FATAL);
#  673|   			}

Error: GCC_ANALYZER_WARNING (CWE-415): [#def38]
libarchive-3.7.2/libarchive/archive_util.c:683:9: warning[-Wanalyzer-double-free]: double-'free' of 'lesser'
#  681|   	for (i = 0; i < lesser_count; i++)
#  682|   		strings[i] = lesser[i];
#  683|-> 	free(lesser);
#  684|   
#  685|   	/* pivot */

Error: GCC_ANALYZER_WARNING (CWE-415): [#def39]
libarchive-3.7.2/libarchive/archive_util.c:692:9: warning[-Wanalyzer-double-free]: double-'free' of 'greater'
#  690|   	for (i = 0; i < greater_count; i++)
#  691|   		strings[lesser_count + 1 + i] = greater[i];
#  692|-> 	free(greater);
#  693|   
#  694|   	return (retval1 < retval2) ? retval1 : retval2;

Error: GCC_ANALYZER_WARNING (CWE-401): [#def40]
libarchive-3.7.2/libarchive/archive_write.c: scope_hint: In function 'archive_write_new'
libarchive-3.7.2/libarchive/archive_write.c:124:17: warning[-Wanalyzer-malloc-leak]: leak of 'a'
#  122|   	}
#  123|   	a->nulls = nulls;
#  124|-> 	return (&a->archive);
#  125|   }
#  126|   

Error: GCC_ANALYZER_WARNING (CWE-401): [#def41]
libarchive-3.7.2/libarchive/archive_write_add_filter_bzip2.c: scope_hint: In function 'archive_compressor_bzip2_open'
libarchive-3.7.2/libarchive/archive_write_add_filter_bzip2.c:184:20: warning[-Wanalyzer-malloc-leak]: leak of 'malloc(bs)'
#  182|   		data->compressed
#  183|   		    = (char *)malloc(data->compressed_buffer_size);
#  184|-> 		if (data->compressed == NULL) {
#  185|   			archive_set_error(f->archive, ENOMEM,
#  186|   			    "Can't allocate data for compression buffer");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def42]
libarchive-3.7.2/libarchive/archive_write_add_filter_gzip.c: scope_hint: In function 'archive_compressor_gzip_open'
libarchive-3.7.2/libarchive/archive_write_add_filter_gzip.c:201:20: warning[-Wanalyzer-malloc-leak]: leak of 'malloc(bs)'
#  199|   		data->compressed
#  200|   		    = (unsigned char *)malloc(data->compressed_buffer_size);
#  201|-> 		if (data->compressed == NULL) {
#  202|   			archive_set_error(f->archive, ENOMEM,
#  203|   			    "Can't allocate data for compression buffer");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def43]
libarchive-3.7.2/libarchive/archive_write_add_filter_xz.c: scope_hint: In function 'archive_compressor_xz_open'
libarchive-3.7.2/libarchive/archive_write_add_filter_xz.c:326:20: warning[-Wanalyzer-malloc-leak]: leak of 'malloc(bs)'
#  324|   		data->compressed
#  325|   		    = (unsigned char *)malloc(data->compressed_buffer_size);
#  326|-> 		if (data->compressed == NULL) {
#  327|   			archive_set_error(f->archive, ENOMEM,
#  328|   			    "Can't allocate data for compression buffer");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def44]
libarchive-3.7.2/libarchive/archive_write_add_filter_zstd.c: scope_hint: In function 'archive_compressor_zstd_open'
libarchive-3.7.2/libarchive/archive_write_add_filter_zstd.c:314:20: warning[-Wanalyzer-malloc-leak]: leak of 'malloc(bs)'
#  312|   		data->out.dst
#  313|   		    = (unsigned char *)malloc(data->out.size);
#  314|-> 		if (data->out.dst == NULL) {
#  315|   			archive_set_error(f->archive, ENOMEM,
#  316|   			    "Can't allocate data for compression buffer");

Error: CLANG_WARNING: [#def45]
libarchive-3.7.2/libarchive/archive_write_open_file.c:92:8: warning[unix.Errno]: An undefined value may be read from 'errno'
#   90|   		bytesWritten = fwrite(buff, 1, length, mine->f);
#   91|   		if (bytesWritten <= 0) {
#   92|-> 			if (errno == EINTR)
#   93|   				continue;
#   94|   			archive_set_error(a, errno, "Write error");

Error: CPPCHECK_WARNING (CWE-401): [#def46]
libarchive-3.7.2/libarchive/archive_write_open_filename.c:114: error[memleak]: Memory leak: mine
#  112|   		if (errno == ENOMEM) {
#  113|   			archive_set_error(a, ENOMEM, "No memory");
#  114|-> 			return (ARCHIVE_FATAL);
#  115|   		}
#  116|   		if (mbs_fn)

Error: CPPCHECK_WARNING (CWE-401): [#def47]
libarchive-3.7.2/libarchive/archive_write_open_filename.c:124: error[memleak]: Memory leak: mine
#  122|   			    "Can't convert '%S' to MBS",
#  123|   			    (const wchar_t *)filename);
#  124|-> 		return (ARCHIVE_FAILED);
#  125|   	}
#  126|   	mine->fd = -1;

Error: GCC_ANALYZER_WARNING (CWE-835): [#def48]
libarchive-3.7.2/libarchive/archive_write_set_format_7zip.c: scope_hint: In function 'compress_out'
libarchive-3.7.2/libarchive/archive_write_set_format_7zip.c:593:21: warning[-Wanalyzer-infinite-loop]: infinite loop
libarchive-3.7.2/libarchive/archive_write_set_format_7zip.c: scope_hint: In function 'compress_out'
#  591|   	for (;;) {
#  592|   		/* Compress file data. */
#  593|-> 		r = compression_code(&(a->archive), &(zip->stream), run);
#  594|   		if (r != ARCHIVE_OK && r != ARCHIVE_EOF)
#  595|   			return (ARCHIVE_FATAL);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def49]
libarchive-3.7.2/libarchive/archive_write_set_format_cpio_binary.c: scope_hint: In function 'synthesize_ino_value'
libarchive-3.7.2/libarchive/archive_write_set_format_cpio_binary.c:325:9: warning[-Wanalyzer-malloc-leak]: leak of 'newlist'
#  323|   	cpio->ino_list[cpio->ino_list_next].old = ino;
#  324|   	cpio->ino_list[cpio->ino_list_next].new = ino_new;
#  325|-> 	++cpio->ino_list_next;
#  326|   	return (ino_new);
#  327|   }

Error: GCC_ANALYZER_WARNING (CWE-476): [#def50]
libarchive-3.7.2/libarchive/archive_write_set_format_iso9660.c: scope_hint: In function 'isoent_rr_move'
libarchive-3.7.2/libarchive/archive_write_set_format_iso9660.c:6791:20: warning[-Wanalyzer-null-dereference]: dereference of NULL '0'
libarchive-3.7.2/libarchive/archive_write_set_format_iso9660.c: scope_hint: In function 'isoent_rr_move'
libarchive-3.7.2/libarchive/archive_write_set_format_iso9660.c: scope_hint: In function 'isoent_rr_move'
# 6789|   		 * its sub directory entries move to rr_move too.
# 6790|   		 */
# 6791|-> 		np = last->ptnext;
# 6792|   	}
# 6793|   

Error: CLANG_WARNING: [#def51]
libarchive-3.7.2/libarchive/archive_write_set_format_iso9660.c:6888:17: warning[core.NullDereference]: Dereference of undefined pointer value (loaded from field 'last')
# 6886|   {
# 6887|   	ent->ptnext = NULL;
# 6888|-> 	*pathtbl->last = ent;
# 6889|   	pathtbl->last = &(ent->ptnext);
# 6890|   	pathtbl->cnt ++;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def52]
libarchive-3.7.2/libarchive/archive_write_set_format_mtree.c: scope_hint: In function 'mtree_entry_tree_add'
libarchive-3.7.2/libarchive/archive_write_set_format_mtree.c:2152:27: warning[-Wanalyzer-null-dereference]: dereference of NULL 'dent'
# 2150|   
# 2151|   		if (!__archive_rb_tree_insert_node(
# 2152|-> 		    &(dent->dir_info->rbtree),
# 2153|   		    (struct archive_rb_node *)file)) {
# 2154|   			np = (struct mtree_entry *)__archive_rb_tree_find_node(

Error: GCC_ANALYZER_WARNING (CWE-688): [#def53]
libarchive-3.7.2/libarchive/archive_write_set_format_shar.c: scope_hint: In function 'archive_write_shar_header'
libarchive-3.7.2/libarchive/archive_write_set_format_shar.c:213:22: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'p' where non-null expected
libarchive-3.7.2/libarchive/archive_write_set_format_shar.c:38: included_from: Included from here.
/usr/include/string.h:273:14: note: argument 1 of 'strrchr' must be non-null
#  211|   		/* Try to create the dir. */
#  212|   		p = strdup(name);
#  213|-> 		pp = strrchr(p, '/');
#  214|   		/* If there is a / character, try to create the dir. */
#  215|   		if (pp != NULL) {

Error: GCC_ANALYZER_WARNING (CWE-688): [#def54]
libarchive-3.7.2/libarchive/archive_write_set_format_shar.c:296:30: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL 'strdup(archive_entry_pathname(entry))' where non-null expected
/usr/include/string.h:273:14: note: argument 1 of 'strrchr' must be non-null
#  294|   			shar->last_dir = strdup(name);
#  295|   			/* Trim a trailing '/'. */
#  296|-> 			pp = strrchr(shar->last_dir, '/');
#  297|   			if (pp != NULL && pp[1] == '\0')
#  298|   				*pp = '\0';

Error: GCC_ANALYZER_WARNING (CWE-476): [#def55]
libarchive-3.7.2/libarchive/xxhash.c:350:17: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL 'state'
libarchive-3.7.2/libarchive/xxhash.c: scope_hint: In function 'XXH32_init'
libarchive-3.7.2/libarchive/xxhash.c:363:19: note: in expansion of macro 'XXH_malloc'
#  348|   {
#  349|       struct XXH_state32_t * state = (struct XXH_state32_t *) state_in;
#  350|->     state->seed = seed;
#  351|       state->v1 = seed + PRIME32_1 + PRIME32_2;
#  352|       state->v2 = seed + PRIME32_2;

Error: CPPCHECK_WARNING (CWE-401): [#def56]
libarchive-3.7.2/libarchive_fe/line_reader.c:79: error[memleak]: Memory leak: lr.f
#   77|   	lr->line_start = lr->line_end = lr->buff_end = lr->buff = NULL;
#   78|   
#   79|-> 	return (lr);
#   80|   }
#   81|   

Error: CPPCHECK_WARNING (CWE-401): [#def57]
libarchive-3.7.2/libarchive_fe/line_reader.c:79: error[memleak]: Memory leak: lr.pathname
#   77|   	lr->line_start = lr->line_end = lr->buff_end = lr->buff = NULL;
#   78|   
#   79|-> 	return (lr);
#   80|   }
#   81|   

Error: CLANG_WARNING: [#def58]
libarchive-3.7.2/libarchive_fe/passphrase.c:188:2: warning[deadcode.DeadStores]: Value stored to 'nr' is never read
#  186|   	for (i = 0; i <= MAX_SIGNO; i++)
#  187|   		signo[i] = 0;
#  188|-> 	nr = -1;
#  189|   	save_errno = 0;
#  190|   	need_restart = 0;

Error: CLANG_WARNING: [#def59]
libarchive-3.7.2/libarchive_fe/passphrase.c:189:2: warning[deadcode.DeadStores]: Value stored to 'save_errno' is never read
#  187|   		signo[i] = 0;
#  188|   	nr = -1;
#  189|-> 	save_errno = 0;
#  190|   	need_restart = 0;
#  191|   	/*

Error: GCC_ANALYZER_WARNING (CWE-775): [#def60]
libarchive-3.7.2/libarchive_fe/passphrase.c: scope_hint: In function 'readpassphrase'
libarchive-3.7.2/libarchive_fe/passphrase.c:210:12: warning[-Wanalyzer-fd-leak]: leak of file descriptor 'open("/dev/tty", 2)'
#  208|   	 * generate SIGTTOU, so do it *before* installing the signal handlers.
#  209|   	 */
#  210|-> 	if (input != STDIN_FILENO && tcgetattr(input, &oterm) == 0) {
#  211|   		memcpy(&term, &oterm, sizeof(term));
#  212|   		if (!(flags & RPP_ECHO_ON))

Error: CPPCHECK_WARNING (CWE-562): [#def61]
libarchive-3.7.2/tar/write.c:359: error[autoVariables]: Address of local auto-variable assigned to a function parameter.
#  357|   	struct archive_dir	 archive_dir;
#  358|   
#  359|-> 	bsdtar->archive_dir = &archive_dir;
#  360|   	memset(&archive_dir, 0, sizeof(archive_dir));
#  361|   

Error: CLANG_WARNING: [#def62]
libarchive-3.7.2/unzip/bsdunzip.c:263:11: warning[core.NullDereference]: Array access (from variable 'str') results in a null pointer dereference
#  261|   	if (L_opt) {
#  262|   		for (i = 0; i < len; ++i)
#  263|-> 			str[i] = tolower((unsigned char)path[i]);
#  264|   	} else {
#  265|   		memcpy(str, path, len);

Error: CLANG_WARNING: [#def63]
libarchive-3.7.2/unzip/bsdunzip.c:265:3: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
#  263|   			str[i] = tolower((unsigned char)path[i]);
#  264|   	} else {
#  265|-> 		memcpy(str, path, len);
#  266|   	}
#  267|   	str[len] = '\0';

Error: CLANG_WARNING: [#def64]
libarchive-3.7.2/unzip/bsdunzip.c:267:11: warning[core.NullDereference]: Array access (from variable 'str') results in a null pointer dereference
#  265|   		memcpy(str, path, len);
#  266|   	}
#  267|-> 	str[len] = '\0';
#  268|   
#  269|   	return (str);

Error: CLANG_WARNING: [#def65]
libarchive-3.7.2/unzip/bsdunzip.c:286:3: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
#  284|   	}
#  285|   	if (prefix) {
#  286|-> 		memcpy(str, prefix, prelen);	/* includes zero */
#  287|   		str[prelen - 1] = '/';		/* splat zero */
#  288|   	}

Error: CLANG_WARNING: [#def66]
libarchive-3.7.2/unzip/bsdunzip.c:289:2: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
#  287|   		str[prelen - 1] = '/';		/* splat zero */
#  288|   	}
#  289|-> 	memcpy(str + prelen, path, len);	/* includes zero */
#  290|   
#  291|   	return (str);

Error: CLANG_WARNING: [#def67]
libarchive-3.7.2/unzip/bsdunzip.c:321:2: warning[core.NonNullParamChecker]: Null pointer passed to 1st parameter expecting 'nonnull'
#  319|   		error("malloc()");
#  320|   	}
#  321|-> 	memcpy(entry->pattern, pattern, len + 1);
#  322|   	STAILQ_INSERT_TAIL(list, entry, link);
#  323|   }

Scan Properties

analyzer-version-clang18.1.3
analyzer-version-cppcheck2.13.0
analyzer-version-gcc14.0.1
analyzer-version-gcc-analyzer14.0.1
analyzer-version-shellcheck0.10.0
enabled-pluginsclang, cppcheck, gcc, shellcheck
exit-code0
hostip-172-16-1-122.us-west-2.compute.internal
mock-configfedora-41-x86_64
project-namelibarchive-3.7.2-3.fc41
store-results-to/tmp/tmphipoiz9p/libarchive-3.7.2-3.fc41.tar.xz
time-created2024-04-22 10:56:04
time-finished2024-04-22 10:58:48
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-41-x86_64' '-t' 'cppcheck,gcc,clang,shellcheck' '-o' '/tmp/tmphipoiz9p/libarchive-3.7.2-3.fc41.tar.xz' '--gcc-analyze' '/tmp/tmphipoiz9p/libarchive-3.7.2-3.fc41.src.rpm'
tool-versioncsmock-3.5.3-1.el9