mtools-4.0.48-1.fc43

List of Findings

Error: SHELLCHECK_WARNING (CWE-138): [#def1]
/usr/bin/tgz:41:20: error[SC2145]: Argument mixes string and array. Use * or separate argument.
#   39|   
#   40|   Error ()
#   41|-> {	echo "Error: $0: ${@-}." >&2
#   42|   	exit 1
#   43|   }

Error: SHELLCHECK_WARNING (CWE-569): [#def2]
/usr/bin/tgz:56:6: warning[SC2124]: Assigning an array to a string! Assign as array, or use * instead of @ to concatenate.
#   54|   	dest=$1
#   55|   	shift
#   56|-> 	src="${@-}"
#   57|   fi
#   58|   

Error: SHELLCHECK_WARNING (CWE-569): [#def3]
/usr/bin/tgz:64:9: warning[SC2221]: This pattern always overrides a later one on line 64.
#   62|   	exit 1
#   63|   	;;
#   64|-> *.t?z | *.?z | *.z | *.Z | *.tz | *.tz? )
#   65|   	;;
#   66|   *)

Error: SHELLCHECK_WARNING (CWE-569): [#def4]
/usr/bin/tgz:64:28: warning[SC2222]: This pattern never matches because of a previous pattern on line 64.
#   62|   	exit 1
#   63|   	;;
#   64|-> *.t?z | *.?z | *.z | *.Z | *.tz | *.tz? )
#   65|   	;;
#   66|   *)

Error: SHELLCHECK_WARNING (CWE-477): [#def5]
/usr/bin/tgz:77:17: warning[SC2166]: Prefer [ p ] || [ q ] as [ p -o q ] is not well defined.
#   75|   	Error "Destination \"$dest\" already exists as a directory"
#   76|   fi
#   77|-> if [ -z "$dest" -o "X$dest" = 'X-' ]; then
#   78|   	echo "Writing gzipp'd tar archive to standard output." >&2
#   79|   	tar cvfS - -- $src | gzip -9v

Error: GCC_ANALYZER_WARNING (CWE-401): [#def6]
mtools-4.0.48/charsetConv.c:85:19: warning[-Wanalyzer-malloc-leak]: leak of ‘iconv_open(asciiTries[i], testCp)’
mtools-4.0.48/charsetConv.c:83:18: branch_true: following ‘true’ branch (when ‘i != 4’)...
mtools-4.0.48/charsetConv.c:84:24: branch_true: ...to here
mtools-4.0.48/charsetConv.c:84:24: acquire_memory: allocated here
mtools-4.0.48/charsetConv.c:85:19: danger: ‘iconv_open(asciiTries[i], testCp)’ leaks here; was allocated at [(3)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/2)
#   83|   	for(i=0; i < sizeof(asciiTries) / sizeof(asciiTries[0]); i++) {
#   84|   		test = iconv_open(asciiTries[i], testCp);
#   85|-> 		if(test != (iconv_t) -1)
#   86|   			break;
#   87|   	}

Error: GCC_ANALYZER_WARNING (CWE-401): [#def7]
mtools-4.0.48/charsetConv.c:138:11: warning[-Wanalyzer-malloc-leak]: leak of ‘iconv_open(wcharCp, & dosCp)’
mtools-4.0.48/charsetConv.c:128:11: branch_false: following ‘false’ branch (when ‘codepage <= 9999’)...
mtools-4.0.48/charsetConv.c:133:12: branch_false: ...to here
mtools-4.0.48/charsetConv.c:133:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:136:9: branch_false: ...to here
mtools-4.0.48/charsetConv.c:137:16: acquire_memory: allocated here
mtools-4.0.48/charsetConv.c:138:11: danger: ‘iconv_open(wcharCp, & dosCp)’ leaks here; was allocated at [(5)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/4)
#  136|   	sprintf(dosCp, "CP%d", codepage);
#  137|   	from = iconv_open(wcharCp, dosCp);
#  138|-> 	if(from == (iconv_t)-1) {
#  139|   		fprintf(stderr, "Error converting to codepage %d %s\n",
#  140|   			codepage, strerror(errno));

Error: GCC_ANALYZER_WARNING (CWE-401): [#def8]
mtools-4.0.48/charsetConv.c:146:11: warning[-Wanalyzer-malloc-leak]: leak of ‘iconv_open(&dosCp,  wcharCp)’
mtools-4.0.48/charsetConv.c:128:11: branch_false: following ‘false’ branch (when ‘codepage <= 9999’)...
mtools-4.0.48/charsetConv.c:133:12: branch_false: ...to here
mtools-4.0.48/charsetConv.c:133:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:136:9: branch_false: ...to here
mtools-4.0.48/charsetConv.c:138:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:144:9: branch_false: ...to here
mtools-4.0.48/charsetConv.c:145:17: acquire_memory: allocated here
mtools-4.0.48/charsetConv.c:146:11: danger: ‘iconv_open(&dosCp,  wcharCp)’ leaks here; was allocated at [(7)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/6)
#  144|   	sprintf(dosCp, "CP%d//TRANSLIT", codepage);
#  145|   	to   =  iconv_open(dosCp, wcharCp);
#  146|-> 	if(to == (iconv_t)-1) {
#  147|   		/* Transliteration not supported? */
#  148|   		sprintf(dosCp, "CP%d", codepage);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def9]
mtools-4.0.48/charsetConv.c:151:11: warning[-Wanalyzer-malloc-leak]: leak of ‘iconv_open(&dosCp,  wcharCp)’
mtools-4.0.48/charsetConv.c:128:11: branch_false: following ‘false’ branch (when ‘codepage <= 9999’)...
mtools-4.0.48/charsetConv.c:133:12: branch_false: ...to here
mtools-4.0.48/charsetConv.c:133:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:136:9: branch_false: ...to here
mtools-4.0.48/charsetConv.c:138:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:144:9: branch_false: ...to here
mtools-4.0.48/charsetConv.c:146:11: branch_true: following ‘true’ branch...
mtools-4.0.48/charsetConv.c:148:17: branch_true: ...to here
mtools-4.0.48/charsetConv.c:149:25: acquire_memory: allocated here
mtools-4.0.48/charsetConv.c:151:11: danger: ‘iconv_open(&dosCp,  wcharCp)’ leaks here; was allocated at [(9)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/8)
#  149|   		to   =  iconv_open(dosCp, wcharCp);
#  150|   	}
#  151|-> 	if(to == (iconv_t)-1) {
#  152|   		iconv_close(from);
#  153|   		fprintf(stderr, "Error converting to codepage %d %s\n",

Error: GCC_ANALYZER_WARNING (CWE-401): [#def10]
mtools-4.0.48/charsetConv.c:159:11: warning[-Wanalyzer-malloc-leak]: leak of ‘iconv_open(wcharCp, & dosCp)’
mtools-4.0.48/charsetConv.c:128:11: branch_false: following ‘false’ branch (when ‘codepage <= 9999’)...
mtools-4.0.48/charsetConv.c:133:12: branch_false: ...to here
mtools-4.0.48/charsetConv.c:133:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:136:9: branch_false: ...to here
mtools-4.0.48/charsetConv.c:137:16: acquire_memory: allocated here
mtools-4.0.48/charsetConv.c:138:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:144:9: branch_false: ...to here
mtools-4.0.48/charsetConv.c:146:11: branch_false: following ‘false’ branch...
mtools-4.0.48/charsetConv.c:158:15: branch_false: ...to here
mtools-4.0.48/charsetConv.c:159:11: danger: ‘iconv_open(wcharCp, & dosCp)’ leaks here; was allocated at [(5)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/4)
#  157|   
#  158|   	ret = New(doscp_t);
#  159|-> 	if(ret == NULL)
#  160|   		return ret;
#  161|   	ret->from = from;

Error: GCC_ANALYZER_WARNING (CWE-457): [#def11]
mtools-4.0.48/charsetConv.c:209:17: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘*mangled’
mtools-4.0.48/charsetConv.c:384:8: enter_function: entry to ‘wchar_to_native’
mtools-4.0.48/charsetConv.c:394:9: call_function: calling ‘initialize_to_native’ from ‘wchar_to_native’
mtools-4.0.48/charsetConv.c:394:9: return_function: returning to ‘wchar_to_native’ from ‘initialize_to_native’
mtools-4.0.48/charsetConv.c:396:11: call_function: calling ‘safe_iconv’ from ‘wchar_to_native’
#  207|   			break;
#  208|   		}
#  209|-> 		*mangled |= 1;
#  210|   
#  211|   		if(out_len <= 0)

Error: GCC_ANALYZER_WARNING (CWE-457): [#def12]
mtools-4.0.48/charsetConv.c:229:25: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘*mangled’
mtools-4.0.48/charsetConv.c:384:8: enter_function: entry to ‘wchar_to_native’
mtools-4.0.48/charsetConv.c:394:9: call_function: calling ‘initialize_to_native’ from ‘wchar_to_native’
mtools-4.0.48/charsetConv.c:394:9: return_function: returning to ‘wchar_to_native’ from ‘initialize_to_native’
mtools-4.0.48/charsetConv.c:396:11: call_function: calling ‘safe_iconv’ from ‘wchar_to_native’
#  227|   		if(dest[i] == '?') {
#  228|   			dest[i] = '_';
#  229|-> 			*mangled |= 1;
#  230|   		}
#  231|   	}

Error: CPPCHECK_WARNING (CWE-401): [#def13]
mtools-4.0.48/config.c:456: error[memleakOnRealloc]: Common realloc mistake: 'devices' nulled but not freed upon failure
#  454|       if(cur_devs >= nr_dev - 2) {
#  455|   	nr_dev = (cur_devs + 2) << 1;
#  456|-> 	if(!(devices=Grow(devices, nr_dev, struct device))){
#  457|   	    printOom();
#  458|   	    exit(1);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def14]
mtools-4.0.48/expand.c:33:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pipefd[0]’
mtools-4.0.48/expand.c:32:11: branch_false: following ‘false’ branch...
mtools-4.0.48/expand.c:35:21: branch_false: ...to here
mtools-4.0.48/expand.c:33:24: danger: ‘pipefd[0]’ leaks here
#   31|   
#   32|   	if(pipe(pipefd)) {
#   33|-> 		return -2;
#   34|   	}
#   35|   	switch((pid=fork())){

Error: GCC_ANALYZER_WARNING (CWE-775): [#def15]
mtools-4.0.48/expand.c:33:24: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘pipefd[1]’
mtools-4.0.48/expand.c:32:11: branch_false: following ‘false’ branch...
mtools-4.0.48/expand.c:35:21: branch_false: ...to here
mtools-4.0.48/expand.c:33:24: danger: ‘pipefd[1]’ leaks here
#   31|   
#   32|   	if(pipe(pipefd)) {
#   33|-> 		return -2;
#   34|   	}
#   35|   	switch((pid=fork())){

Error: GCC_ANALYZER_WARNING (CWE-775): [#def16]
mtools-4.0.48/expand.c:43:27: warning[-Wanalyzer-fd-leak]: leak of file descriptor ‘dup(pipefd[1])’
mtools-4.0.48/expand.c:32:11: branch_false: following ‘false’ branch...
mtools-4.0.48/expand.c:35:21: branch_false: ...to here
mtools-4.0.48/expand.c:43:28: acquire_resource: opened here
mtools-4.0.48/expand.c:43:27: danger: ‘dup(pipefd[1])’ leaks here; was opened at [(6)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/5)
#   41|   			close(1);
#   42|   			close(2); /* avoid nasty error messages on stderr */
#   43|-> 			if(dup(pipefd[1]) < 0) {
#   44|   				perror("Dup error");
#   45|   				exit(1);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def17]
mtools-4.0.48/fat.c:186:17: warning[-Wanalyzer-malloc-leak]: leak of ‘malloc((long unsigned int)*This.sector_size * 64)’
mtools-4.0.48/fat.c:753:5: enter_function: entry to ‘fat_read’
mtools-4.0.48/fat.c:762:9: branch_true: following ‘true’ branch...
mtools-4.0.48/fat.c:763:11: branch_true: ...to here
mtools-4.0.48/fat.c:763:11: branch_true: following ‘true’ branch...
mtools-4.0.48/fat.c:764:24: branch_true: ...to here
mtools-4.0.48/fat.c:764:24: call_function: calling ‘old_fat_read’ from ‘fat_read’
#  184|   		if(!This->FatMap[slot].data)
#  185|   			return 0;
#  186|-> 		memset(This->FatMap[slot].data, 0xee,
#  187|   		       This->sector_size * SECT_PER_ENTRY);
#  188|   	}

Error: CPPCHECK_WARNING (CWE-401): [#def18]
mtools-4.0.48/init.c:520: error[memleak]: Memory leak: This
#  518|   				      &maxSize, isRop);
#  519|   	if(!This->head.Next)
#  520|-> 		return NULL;
#  521|   
#  522|   	cylinder_size = dev.heads * dev.sectors;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def19]
mtools-4.0.48/init.c:610:24: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘Stream’
mtools-4.0.48/init.c:603:6: enter_function: entry to ‘getDrive’
mtools-4.0.48/init.c:607:11: branch_true: following ‘true’ branch...
 branch_true: ...to here
mtools-4.0.48/init.c:608:24: call_function: inlined call to ‘GetFs’ from ‘getDrive’
mtools-4.0.48/init.c:610:24: danger: dereference of NULL ‘Stream’
#  608|   		return getDrive(GetFs(Stream));
#  609|   	else
#  610|-> 		return This->drive;
#  611|   }
#  612|   

Error: CPPCHECK_WARNING (CWE-476): [#def20]
mtools-4.0.48/mainloop.c:105: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: name
#  103|   	    /* names ending in slash, and having at least two characters */
#  104|   	    char *name = strdup(arg);
#  105|-> 	    name[unixNameLength-1]='\0';
#  106|   	    mp->unixSourceName = name;
#  107|   	} else {

Error: CPPCHECK_WARNING (CWE-562): [#def21]
mtools-4.0.48/mainloop.c:262: error[autoVariables]: Address of local auto-variable assigned to a function parameter.
#  260|   			if(got_signal)
#  261|   				break;
#  262|-> 			mp->direntry = &entry;
#  263|   			if(IS_DIR(&entry))
#  264|   				ret |= mp->dirCallback(&entry,mp);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def22]
mtools-4.0.48/mbadblocks.c:220:23: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(filename, "r")’
mtools-4.0.48/mbadblocks.c:111:6: enter_function: entry to ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:125:16: branch_true: following ‘true’ branch (when ‘c != -1’)...
mtools-4.0.48/mbadblocks.c:126:17: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:131:25: call_function: inlined call to ‘checkListTwice’ from ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:132:36: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:18: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:33: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:161:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:166:22: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:169:11: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:174:11: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:174:11: branch_false: following ‘false’ branch (when ‘writeMode == 0’)...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:186:18: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:203:19: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:210:11: branch_true: following ‘true’ branch (when ‘filename’ is non-NULL)...
mtools-4.0.48/mbadblocks.c:213:27: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:213:27: acquire_resource: opened here
mtools-4.0.48/mbadblocks.c:214:19: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:220:23: danger: ‘fopen(filename, "r")’ leaks here; was opened at [(23)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/22)
#  218|   			goto exit_0;
#  219|   		}
#  220|-> 		while(fgets(line, sizeof(line), f)) {
#  221|   			char *ptr = line + strspn(line, " \t");
#  222|   			uint32_t offset = strtou32(ptr, 0, 0);

Error: GCC_ANALYZER_WARNING (CWE-401): [#def23]
mtools-4.0.48/mbadblocks.c:220:23: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(filename, "r")’
mtools-4.0.48/mbadblocks.c:111:6: enter_function: entry to ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:125:16: branch_true: following ‘true’ branch (when ‘c != -1’)...
mtools-4.0.48/mbadblocks.c:126:17: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:131:25: call_function: inlined call to ‘checkListTwice’ from ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:132:36: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:18: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:33: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:161:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:166:22: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:169:11: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:174:11: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:174:11: branch_false: following ‘false’ branch (when ‘writeMode == 0’)...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:186:18: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:203:19: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:210:11: branch_true: following ‘true’ branch (when ‘filename’ is non-NULL)...
mtools-4.0.48/mbadblocks.c:213:27: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:213:27: acquire_memory: allocated here
mtools-4.0.48/mbadblocks.c:214:19: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:220:23: danger: ‘fopen(filename, "r")’ leaks here; was allocated at [(23)](sarif:/runs/0/results/1/codeFlows/0/threadFlows/0/locations/22)
#  218|   			goto exit_0;
#  219|   		}
#  220|-> 		while(fgets(line, sizeof(line), f)) {
#  221|   			char *ptr = line + strspn(line, " \t");
#  222|   			uint32_t offset = strtou32(ptr, 0, 0);

Error: GCC_ANALYZER_WARNING (CWE-775): [#def24]
mtools-4.0.48/mbadblocks.c:226:33: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(filename, "r")’
mtools-4.0.48/mbadblocks.c:111:6: enter_function: entry to ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:125:16: branch_true: following ‘true’ branch (when ‘c != -1’)...
mtools-4.0.48/mbadblocks.c:126:17: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:131:25: call_function: inlined call to ‘checkListTwice’ from ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:132:36: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:18: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:33: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:161:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:166:22: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:169:11: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:174:11: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:174:11: branch_false: following ‘false’ branch (when ‘writeMode == 0’)...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:186:18: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:203:19: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:210:11: branch_true: following ‘true’ branch (when ‘filename’ is non-NULL)...
mtools-4.0.48/mbadblocks.c:213:27: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:213:27: acquire_resource: opened here
mtools-4.0.48/mbadblocks.c:214:19: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:220:23: branch_true: following ‘true’ branch...
mtools-4.0.48/mbadblocks.c:221:44: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:226:33: danger: ‘fopen(filename, "r")’ leaks here; was opened at [(23)](sarif:/runs/0/results/2/codeFlows/0/threadFlows/0/locations/22)
#  224|   				offset = (offset-Fs->clus_start)/Fs->cluster_size + 2;
#  225|   			if(offset < 2) {
#  226|-> 				fprintf(stderr, "Sector before start\n");
#  227|   			} else if(offset >= Fs->num_clus) {
#  228|   				fprintf(stderr, "Sector beyond end\n");

Error: GCC_ANALYZER_WARNING (CWE-401): [#def25]
mtools-4.0.48/mbadblocks.c:226:33: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(filename, "r")’
mtools-4.0.48/mbadblocks.c:111:6: enter_function: entry to ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:125:16: branch_true: following ‘true’ branch (when ‘c != -1’)...
mtools-4.0.48/mbadblocks.c:126:17: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:131:25: call_function: inlined call to ‘checkListTwice’ from ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:132:36: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:18: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:33: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:161:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:166:22: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:169:11: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:174:11: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:174:11: branch_false: following ‘false’ branch (when ‘writeMode == 0’)...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:186:18: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:203:19: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:210:11: branch_true: following ‘true’ branch (when ‘filename’ is non-NULL)...
mtools-4.0.48/mbadblocks.c:213:27: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:213:27: acquire_memory: allocated here
mtools-4.0.48/mbadblocks.c:214:19: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:220:23: branch_true: following ‘true’ branch...
mtools-4.0.48/mbadblocks.c:221:44: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:226:33: danger: ‘fopen(filename, "r")’ leaks here; was allocated at [(23)](sarif:/runs/0/results/3/codeFlows/0/threadFlows/0/locations/22)
#  224|   				offset = (offset-Fs->clus_start)/Fs->cluster_size + 2;
#  225|   			if(offset < 2) {
#  226|-> 				fprintf(stderr, "Sector before start\n");
#  227|   			} else if(offset >= Fs->num_clus) {
#  228|   				fprintf(stderr, "Sector beyond end\n");

Error: GCC_ANALYZER_WARNING (CWE-775): [#def26]
mtools-4.0.48/mbadblocks.c:227:45: warning[-Wanalyzer-file-leak]: leak of FILE ‘fopen(filename, "r")’
mtools-4.0.48/mbadblocks.c:111:6: enter_function: entry to ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:125:16: branch_true: following ‘true’ branch (when ‘c != -1’)...
mtools-4.0.48/mbadblocks.c:126:17: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:131:25: call_function: inlined call to ‘checkListTwice’ from ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:132:36: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:18: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:33: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:161:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:166:22: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:169:11: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:174:11: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:186:18: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:203:19: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:210:11: branch_true: following ‘true’ branch (when ‘filename’ is non-NULL)...
mtools-4.0.48/mbadblocks.c:213:27: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:213:27: acquire_resource: opened here
mtools-4.0.48/mbadblocks.c:214:19: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:220:23: branch_true: following ‘true’ branch...
mtools-4.0.48/mbadblocks.c:221:44: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:227:45: danger: ‘fopen(filename, "r")’ leaks here; was opened at [(21)](sarif:/runs/0/results/4/codeFlows/0/threadFlows/0/locations/20)
#  225|   			if(offset < 2) {
#  226|   				fprintf(stderr, "Sector before start\n");
#  227|-> 			} else if(offset >= Fs->num_clus) {
#  228|   				fprintf(stderr, "Sector beyond end\n");
#  229|   			} else {

Error: GCC_ANALYZER_WARNING (CWE-401): [#def27]
mtools-4.0.48/mbadblocks.c:227:45: warning[-Wanalyzer-malloc-leak]: leak of ‘fopen(filename, "r")’
mtools-4.0.48/mbadblocks.c:111:6: enter_function: entry to ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:125:16: branch_true: following ‘true’ branch (when ‘c != -1’)...
mtools-4.0.48/mbadblocks.c:126:17: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:131:25: call_function: inlined call to ‘checkListTwice’ from ‘mbadblocks’
mtools-4.0.48/mbadblocks.c:132:36: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:18: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:156:33: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:155:13: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:161:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:166:22: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:169:11: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:174:11: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:186:18: branch_false: following ‘false’ branch...
mtools-4.0.48/mbadblocks.c:203:19: branch_false: ...to here
mtools-4.0.48/mbadblocks.c:210:11: branch_true: following ‘true’ branch (when ‘filename’ is non-NULL)...
mtools-4.0.48/mbadblocks.c:213:27: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:213:27: acquire_memory: allocated here
mtools-4.0.48/mbadblocks.c:214:19: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/mbadblocks.c:220:23: branch_true: following ‘true’ branch...
mtools-4.0.48/mbadblocks.c:221:44: branch_true: ...to here
mtools-4.0.48/mbadblocks.c:227:45: danger: ‘fopen(filename, "r")’ leaks here; was allocated at [(21)](sarif:/runs/0/results/5/codeFlows/0/threadFlows/0/locations/20)
#  225|   			if(offset < 2) {
#  226|   				fprintf(stderr, "Sector before start\n");
#  227|-> 			} else if(offset >= Fs->num_clus) {
#  228|   				fprintf(stderr, "Sector beyond end\n");
#  229|   			} else {

Error: GCC_ANALYZER_WARNING (CWE-476): [#def28]
mtools-4.0.48/mcat.c:132:37: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘Stream’
mtools-4.0.48/mcat.c:52:6: enter_function: entry to ‘mcat’
mtools-4.0.48/mcat.c:69:12: branch_false: following ‘false’ branch (when ‘argc > 1’)...
 branch_false: ...to here
mtools-4.0.48/mcat.c:86:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:88:11: branch_false: ...to here
mtools-4.0.48/mcat.c:98:9: release_memory: ‘Stream’ is NULL
mtools-4.0.48/mcat.c:99:27: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:118:14: branch_false: ...to here
mtools-4.0.48/mcat.c:118:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:121:12: branch_false: ...to here
mtools-4.0.48/mcat.c:121:12: branch_true: following ‘true’ branch (when ‘mode == 1’)...
mtools-4.0.48/mcat.c:124:20: branch_true: ...to here
mtools-4.0.48/mcat.c:124:19: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:125:20: branch_false: ...to here
mtools-4.0.48/mcat.c:124:20: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:128:41: branch_false: ...to here
mtools-4.0.48/mcat.c:129:31: call_function: inlined call to ‘bufLen’ from ‘mcat’
mtools-4.0.48/mcat.c:129:31: branch_true: ...to here
mtools-4.0.48/mcat.c:129:24: branch_true: following ‘true’ branch...
mtools-4.0.48/mcat.c:132:37: branch_true: ...to here
mtools-4.0.48/mcat.c:132:37: release_memory: ‘Stream’ is NULL
mtools-4.0.48/mcat.c:132:37: danger: dereference of NULL ‘Stream’
#  130|   				    bufLen(BUF_SIZE, size, address),
#  131|   				    stdin)) > 0) {
#  132|-> 			ssize_t r = PWRITES(Stream, buf, address, len);
#  133|   			fprintf(stderr, "Wrote to %d\n", (int) address);
#  134|   			if(r < 0)

Error: GCC_ANALYZER_WARNING (CWE-476): [#def29]
mtools-4.0.48/mcat.c:140:31: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘Stream’
mtools-4.0.48/mcat.c:69:12: branch_false: following ‘false’ branch (when ‘argc > 1’)...
 branch_false: ...to here
mtools-4.0.48/mcat.c:86:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:88:11: branch_false: ...to here
mtools-4.0.48/mcat.c:98:9: release_memory: ‘Stream’ is NULL
mtools-4.0.48/mcat.c:99:27: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:118:14: branch_false: ...to here
mtools-4.0.48/mcat.c:118:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mcat.c:121:12: branch_false: ...to here
mtools-4.0.48/mcat.c:121:12: branch_false: following ‘false’ branch (when ‘mode != 1’)...
 branch_false: ...to here
mtools-4.0.48/mcat.c:140:31: release_memory: ‘Stream’ is NULL
mtools-4.0.48/mcat.c:140:31: danger: dereference of NULL ‘Stream’
#  138|   	} else {
#  139|   		ssize_t len;
#  140|-> 		while ((len = PREADS(Stream, buf, address, BUF_SIZE)) > 0) {
#  141|   			fwrite(buf, 1, (size_t) len, stdout);
#  142|   			address += (size_t) len;

Error: GCC_ANALYZER_WARNING (CWE-688): [#def30]
mtools-4.0.48/mcopy.c:136:12: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘*arg.unixTarget’ where non-null expected
mtools-4.0.48/mcopy.c:134:27: acquire_memory: this call could return NULL
mtools-4.0.48/mcopy.c:136:12: danger: argument 1 (‘strdup(in)’) from [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0) could be NULL where non-null expected
#  134|   	arg->unixTarget = strdup(in);
#  135|   	/* try complete filename */
#  136|-> 	if(access(arg->unixTarget, F_OK) == 0) {
#  137|   		switch(unix_is_dir(arg->unixTarget)) {
#  138|   		case -1:

Error: GCC_ANALYZER_WARNING (CWE-688): [#def31]
mtools-4.0.48/mcopy.c:136:12: warning[-Wanalyzer-possible-null-argument]: use of possibly-NULL ‘arg.unixTarget’ where non-null expected
mtools-4.0.48/mcopy.c:594:6: enter_function: entry to ‘mcopy’
mtools-4.0.48/mcopy.c:614:11: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/mcopy.c:668:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mcopy.c:671:9: branch_false: ...to here
mtools-4.0.48/mcopy.c:681:11: branch_true: following ‘true’ branch (when ‘mtype == 0’)...
mtools-4.0.48/mcopy.c:681:34: branch_true: ...to here
mtools-4.0.48/mcopy.c:681:12: branch_false: following ‘false’ branch (when the strings are non-equal)...
mtools-4.0.48/mcopy.c:693:21: branch_false: ...to here
mtools-4.0.48/mcopy.c:703:20: call_function: calling ‘target_lookup’ from ‘mcopy’
#  134|   	arg->unixTarget = strdup(in);
#  135|   	/* try complete filename */
#  136|-> 	if(access(arg->unixTarget, F_OK) == 0) {
#  137|   		switch(unix_is_dir(arg->unixTarget)) {
#  138|   		case -1:

Error: GCC_ANALYZER_WARNING (CWE-415): [#def32]
mtools-4.0.48/mdir.c:305:25: warning[-Wanalyzer-double-free]: double-‘free’ of ‘dynDirPath’
mtools-4.0.48/mdir.c:460:12: enter_function: entry to ‘list_non_recurs_directory’
mtools-4.0.48/mdir.c:473:19: call_function: calling ‘enterDirectory’ from ‘list_non_recurs_directory’
#  303|   	if (!haveError) {
#  304|   		if(dirPath && dirPath != emptyString)
#  305|-> 			free(dynDirPath);
#  306|   		if(wide)
#  307|   			putchar('\n');

Error: GCC_ANALYZER_WARNING (CWE-476): [#def33]
mtools-4.0.48/mk_direntry.c:571:13: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘argname’
mtools-4.0.48/mk_direntry.c:646:5: enter_function: entry to ‘mwrite_one’
mtools-4.0.48/mk_direntry.c:657:11: branch_true: following ‘true’ branch (when ‘_argname’ is non-NULL)...
mtools-4.0.48/mk_direntry.c:658:27: branch_true: ...to here
mtools-4.0.48/mk_direntry.c:658:27: acquire_memory: allocated here
mtools-4.0.48/mk_direntry.c:661:11: branch_true: following ‘true’ branch (when ‘_shortname’ is non-NULL)...
mtools-4.0.48/mk_direntry.c:662:29: branch_true: ...to here
mtools-4.0.48/mk_direntry.c:665:15: call_function: calling ‘mt_mwrite_one’ from ‘mwrite_one’
#  569|   	}
#  570|   
#  571|-> 	if (argname[0] && (argname[1] == ':')) {
#  572|   		/* Skip drive letter */
#  573|   		dstname = argname + 2;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def34]
mtools-4.0.48/mk_direntry.c:571:13: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘argname’
mtools-4.0.48/mk_direntry.c:646:5: enter_function: entry to ‘mwrite_one’
mtools-4.0.48/mk_direntry.c:657:11: branch_true: following ‘true’ branch (when ‘_argname’ is non-NULL)...
mtools-4.0.48/mk_direntry.c:658:27: branch_true: ...to here
mtools-4.0.48/mk_direntry.c:658:27: acquire_memory: this call could return NULL
mtools-4.0.48/mk_direntry.c:661:11: branch_true: following ‘true’ branch (when ‘_shortname’ is non-NULL)...
mtools-4.0.48/mk_direntry.c:662:29: branch_true: ...to here
mtools-4.0.48/mk_direntry.c:665:15: call_function: calling ‘mt_mwrite_one’ from ‘mwrite_one’
#  569|   	}
#  570|   
#  571|-> 	if (argname[0] && (argname[1] == ':')) {
#  572|   		/* Skip drive letter */
#  573|   		dstname = argname + 2;

Error: GCC_ANALYZER_WARNING (CWE-775): [#def35]
mtools-4.0.48/mmount.c:71:17: warning[-Wanalyzer-fd-leak]: leak of file descriptor
mtools-4.0.48/mmount.c:35:6: enter_function: entry to ‘mmount’
mtools-4.0.48/mmount.c:46:12: branch_false: following ‘false’ branch...
mtools-4.0.48/mmount.c:52:11: branch_false: following ‘false’ branch...
mtools-4.0.48/mmount.c:54:9: branch_false: ...to here
mtools-4.0.48/mmount.c:71:17: danger: leaks here
#   69|   	case 0:
#   70|   		close(2);
#   71|-> 		open("/dev/null", O_RDWR | O_BINARY | O_LARGEFILE);
#   72|   		argv[1] = strdup("mount");
#   73|   		if ( argc > 2 )

Error: COMPILER_WARNING (CWE-252): [#def36]
mtools-4.0.48/privileges.c: scope_hint: In function ‘Setuid’
mtools-4.0.48/privileges.c:98:17: warning[-Wunused-result]: ignoring return value of ‘seteuid’ declared with attribute ‘warn_unused_result’
#   98 |                 seteuid(uid);
#      |                 ^~~~~~~~~~~~
#   96|   	if(euid == 0) {
#   97|   #ifdef HAVE_SETEUID
#   98|-> 		seteuid(uid);
#   99|   #else
#  100|   		setresuid(ruid, uid, euid);

Error: COMPILER_WARNING (CWE-252): [#def37]
mtools-4.0.48/privileges.c:104:17: warning[-Wunused-result]: ignoring return value of ‘setuid’ declared with attribute ‘warn_unused_result’
#  104 |                 setuid(uid);
#      |                 ^~~~~~~~~~~
#  102|   	} else
#  103|   #endif
#  104|-> 		setuid(uid);
#  105|   }
#  106|   

Error: COMPILER_WARNING (CWE-252): [#def38]
mtools-4.0.48/privileges.c: scope_hint: In function ‘reclaim_privs’
mtools-4.0.48/privileges.c:114:9: warning[-Wunused-result]: ignoring return value of ‘setgid’ declared with attribute ‘warn_unused_result’
#  114 |         setgid(egid);
#      |         ^~~~~~~~~~~~
#  112|   	if(noPrivileges)
#  113|   		return;
#  114|-> 	setgid(egid);
#  115|   	Setuid(euid);
#  116|   	print_privs("after reclaim privs, both uids should be 0 ");

Error: COMPILER_WARNING (CWE-252): [#def39]
mtools-4.0.48/privileges.c: scope_hint: In function ‘drop_privs’
mtools-4.0.48/privileges.c:122:9: warning[-Wunused-result]: ignoring return value of ‘setgid’ declared with attribute ‘warn_unused_result’
#  122 |         setgid(rgid);
#      |         ^~~~~~~~~~~~
#  120|   {
#  121|   	Setuid(ruid);
#  122|-> 	setgid(rgid);
#  123|   	print_privs("after drop_privs, real should be 0, effective should not ");
#  124|   }

Error: COMPILER_WARNING (CWE-252): [#def40]
mtools-4.0.48/privileges.c: scope_hint: In function ‘destroy_privs’
mtools-4.0.48/privileges.c:132:17: warning[-Wunused-result]: ignoring return value of ‘setuid’ declared with attribute ‘warn_unused_result’
#  132 |                 setuid(0); /* get the necessary privs to drop real root id */
#      |                 ^~~~~~~~~
#  130|   	if(euid == 0) {
#  131|   #ifdef HAVE_SETEUID
#  132|-> 		setuid(0); /* get the necessary privs to drop real root id */
#  133|   		setuid(ruid); /* this should be enough to get rid of the three
#  134|   			       * ids */

Error: COMPILER_WARNING (CWE-252): [#def41]
mtools-4.0.48/privileges.c:133:17: warning[-Wunused-result]: ignoring return value of ‘setuid’ declared with attribute ‘warn_unused_result’
#  133 |                 setuid(ruid); /* this should be enough to get rid of the three
#      |                 ^~~~~~~~~~~~
#  131|   #ifdef HAVE_SETEUID
#  132|   		setuid(0); /* get the necessary privs to drop real root id */
#  133|-> 		setuid(ruid); /* this should be enough to get rid of the three
#  134|   			       * ids */
#  135|   		seteuid(ruid); /* for good measure... just in case we came

Error: COMPILER_WARNING (CWE-252): [#def42]
mtools-4.0.48/privileges.c:135:17: warning[-Wunused-result]: ignoring return value of ‘seteuid’ declared with attribute ‘warn_unused_result’
#  135 |                 seteuid(ruid); /* for good measure... just in case we came
#      |                 ^~~~~~~~~~~~~
#  133|   		setuid(ruid); /* this should be enough to get rid of the three
#  134|   			       * ids */
#  135|-> 		seteuid(ruid); /* for good measure... just in case we came
#  136|   				* across a system which implemented sane
#  137|   				* semantics instead of POSIXly broken

Error: COMPILER_WARNING (CWE-252): [#def43]
mtools-4.0.48/privileges.c: scope_hint: In function ‘init_privs’
mtools-4.0.48/privileges.c:183:17: warning[-Wunused-result]: ignoring return value of ‘setuid’ declared with attribute ‘warn_unused_result’
#  183 |                 setuid(0); /* set real uid to 0 */
#      |                 ^~~~~~~~~
#  181|   	if(euid == 0 && ruid != 0) {
#  182|   #ifdef HAVE_SETEUID
#  183|-> 		setuid(0); /* set real uid to 0 */
#  184|   #else
#  185|   #ifndef HAVE_SETRESUID

Error: CPPCHECK_WARNING (CWE-476): [#def44]
mtools-4.0.48/swap.c:32: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: buf
#   30|   	unsigned int i;
#   31|   	for (i=0; i<len; i+=2) {
#   32|-> 		char temp = buf[i];
#   33|   		buf[i] = buf[i+1];
#   34|   		buf[i+1] = temp;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def45]
mtools-4.0.48/swap.c:32:22: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘buf’
mtools-4.0.48/swap.c:51:16: enter_function: entry to ‘swap_pwrite’
mtools-4.0.48/swap.c:57:26: acquire_memory: this call could return NULL
mtools-4.0.48/swap.c:59:9: call_function: calling ‘swap_buffer’ from ‘swap_pwrite’
#   30|   	unsigned int i;
#   31|   	for (i=0; i<len; i+=2) {
#   32|-> 		char temp = buf[i];
#   33|   		buf[i] = buf[i+1];
#   34|   		buf[i+1] = temp;

Error: CPPCHECK_WARNING (CWE-476): [#def46]
mtools-4.0.48/swap.c:33: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: buf
#   31|   	for (i=0; i<len; i+=2) {
#   32|   		char temp = buf[i];
#   33|-> 		buf[i] = buf[i+1];
#   34|   		buf[i+1] = temp;
#   35|   	}

Error: CPPCHECK_WARNING (CWE-476): [#def47]
mtools-4.0.48/swap.c:34: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: buf
#   32|   		char temp = buf[i];
#   33|   		buf[i] = buf[i+1];
#   34|-> 		buf[i+1] = temp;
#   35|   	}
#   36|   }

Error: CPPCHECK_WARNING (CWE-476): [#def48]
mtools-4.0.48/swap.c:58: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: swapping
#   56|   	ssize_t result;
#   57|   	char *swapping = malloc( len );
#   58|-> 	memcpy( swapping, buf, len );
#   59|   	swap_buffer( swapping, len );
#   60|   

Error: GCC_ANALYZER_WARNING (CWE-688): [#def49]
mtools-4.0.48/tty.c:221:33: warning[-Wanalyzer-null-argument]: use of NULL where non-null expected
mtools-4.0.48/tty.c:206:5: enter_function: entry to ‘ask_confirmation’
mtools-4.0.48/tty.c:211:13: call_function: calling ‘opentty’ from ‘ask_confirmation’
mtools-4.0.48/tty.c:211:13: return_function: returning to ‘ask_confirmation’ from ‘opentty’
mtools-4.0.48/tty.c:211:11: branch_false: following ‘false’ branch...
 branch_false: ...to here
mtools-4.0.48/tty.c:219:17: call_function: calling ‘opentty’ from ‘ask_confirmation’
mtools-4.0.48/tty.c:219:17: return_function: returning to ‘ask_confirmation’ from ‘opentty’
mtools-4.0.48/tty.c:220:20: branch_true: following ‘true’ branch...
mtools-4.0.48/tty.c:221:33: branch_true: ...to here
mtools-4.0.48/tty.c:221:33: danger: argument 1 (‘opentty(1)’) NULL where non-null expected
#  219|   		fflush(opentty(-1));
#  220|   		if (mtools_raw_tty) {
#  221|-> 			int c = fgetc(opentty(1));
#  222|   			if(c < 0)
#  223|   				/* Treat end-of-file or error as no */

Error: CPPCHECK_WARNING (CWE-476): [#def50]
mtools-4.0.48/unixdir.c:158: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: This
#  156|   	This = New(Dir_t);
#  157|   	init_head(&This->head, &DirClass, NULL);
#  158|-> 	This->pathname = malloc(strlen(filename)+1);
#  159|   	if(This->pathname == NULL) {
#  160|   		Free(This);

Error: GCC_ANALYZER_WARNING (CWE-476): [#def51]
mtools-4.0.48/unixdir.c:158:9: warning[-Wanalyzer-possible-null-dereference]: dereference of possibly-NULL ‘This’
mtools-4.0.48/unixdir.c:156:16: acquire_memory: this call could return NULL
mtools-4.0.48/unixdir.c:158:9: danger: ‘This’ could be NULL: unchecked value from [(1)](sarif:/runs/0/results/0/codeFlows/0/threadFlows/0/locations/0)
#  156|   	This = New(Dir_t);
#  157|   	init_head(&This->head, &DirClass, NULL);
#  158|-> 	This->pathname = malloc(strlen(filename)+1);
#  159|   	if(This->pathname == NULL) {
#  160|   		Free(This);

Error: CPPCHECK_WARNING (CWE-476): [#def52]
mtools-4.0.48/unixdir.c:159: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: This
#  157|   	init_head(&This->head, &DirClass, NULL);
#  158|   	This->pathname = malloc(strlen(filename)+1);
#  159|-> 	if(This->pathname == NULL) {
#  160|   		Free(This);
#  161|   		return NULL;

Error: CPPCHECK_WARNING (CWE-476): [#def53]
mtools-4.0.48/unixdir.c:163: warning[nullPointerOutOfMemory]: If memory allocation fails, then there is a possible null pointer dereference: This
#  161|   		return NULL;
#  162|   	}
#  163|-> 	strcpy(This->pathname, filename);
#  164|   
#  165|   	if(MT_STAT(filename, &This->statbuf) < 0) {

Error: GCC_ANALYZER_WARNING (CWE-457): [#def54]
mtools-4.0.48/vfat.c:420:12: warning[-Wanalyzer-use-of-uninitialized-value]: use of uninitialized value ‘*v.sum’
mtools-4.0.48/vfat.c:730:32: enter_function: entry to ‘vfat_lookup_loop_for_insert’
mtools-4.0.48/vfat.c:743:23: call_function: calling ‘vfat_lookup_loop_common’ from ‘vfat_lookup_loop_for_insert’
#  418|   
#  419|   	/* bad checksum, begin new chain */
#  420|-> 	if(v->sum != vse->sum) {
#  421|   		clear_vfat(v);
#  422|   		v->sum = vse->sum;

Error: GCC_ANALYZER_WARNING (CWE-476): [#def55]
mtools-4.0.48/vfat.c:845:24: warning[-Wanalyzer-null-dereference]: dereference of NULL ‘0’
mtools-4.0.48/vfat.c:790:5: enter_function: entry to ‘lookupForInsert’
mtools-4.0.48/vfat.c:821:11: branch_false: following ‘false’ branch...
mtools-4.0.48/vfat.c:826:11: branch_false: ...to here
mtools-4.0.48/vfat.c:844:23: call_function: calling ‘vfat_lookup_loop_for_insert’ from ‘lookupForInsert’
mtools-4.0.48/vfat.c:844:23: return_function: returning to ‘lookupForInsert’ from ‘vfat_lookup_loop_for_insert’
mtools-4.0.48/vfat.c:845:24: danger: dereference of NULL ‘vfat_lookup_loop_for_insert(*Dir_53(D)->Class.get_dosConvert(Dir), &entry,  pos,  allocDirCache(Dir, 1))’
#  843|   	do {
#  844|   		dce = vfat_lookup_loop_for_insert(cp, &entry, pos, cache);
#  845|-> 		switch(dce->type) {
#  846|   			case DCET_FREE:
#  847|   				accountFreeSlots(ssp, dce);

Scan Properties

analyzer-version-clippy1.86.0
analyzer-version-cppcheck2.17.1
analyzer-version-gcc15.0.1
analyzer-version-gcc-analyzer15.0.1
analyzer-version-shellcheck0.10.0
analyzer-version-unicontrol0.0.2
enabled-pluginsclippy, cppcheck, gcc, shellcheck, unicontrol
exit-code0
hostip-172-16-1-83.us-west-2.compute.internal
known-false-positives/usr/share/csmock/known-false-positives.js
known-false-positives-rpmknown-false-positives-0.0.0.20250425.124705.g1c7c448.main-1.el9.noarch
mock-configfedora-rawhide-x86_64
project-namemtools-4.0.48-1.fc43
store-results-to/tmp/tmpr0p2_41v/mtools-4.0.48-1.fc43.tar.xz
time-created2025-04-25 14:28:34
time-finished2025-04-25 14:30:03
toolcsmock
tool-args'/usr/bin/csmock' '-r' 'fedora-rawhide-x86_64' '-t' 'unicontrol,cppcheck,gcc,clippy,shellcheck' '-o' '/tmp/tmpr0p2_41v/mtools-4.0.48-1.fc43.tar.xz' '--gcc-analyze' '--unicontrol-notests' '--unicontrol-bidi-only' '--install' 'pam' '--gcc-analyzer-bin=/usr/bin/gcc' '/tmp/tmpr0p2_41v/mtools-4.0.48-1.fc43.src.rpm'
tool-versioncsmock-3.8.1.20250422.172604.g26bc3d6-1.el9