Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler.
Number of rules (primarily dangerous function names) in C/C++ ruleset: 223
Examining data/stenc-1.0.7/src/scsiencrypt.cpp
Examining data/stenc-1.0.7/src/scsiencrypt.h
Examining data/stenc-1.0.7/src/keyinfo.h
Examining data/stenc-1.0.7/src/keyinfo.cpp
Examining data/stenc-1.0.7/src/main.cpp

FINAL RESULTS:

data/stenc-1.0.7/src/main.cpp:197:13:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
            chmod(keyFile.c_str(),0600);
data/stenc-1.0.7/src/main.cpp:227:5:  [5] (race) chmod:
  This accepts filename arguments; if an attacker can move those files, a
  race condition results. (CWE-362). Use fchmod( ) instead.
    chmod(LOGFILE,0600);	
data/stenc-1.0.7/src/main.cpp:562:2:  [3] (random) srand:
  This function is not sufficiently random for security-related functions
  such as key and nonce creation (CWE-327). Use a more secure technique for
  acquiring random values.
	srand(time(NULL)+(int)check);
data/stenc-1.0.7/src/main.cpp:78:5:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
    memcpy(&check,&bc,1);
data/stenc-1.0.7/src/main.cpp:120:16:  [2] (integer) atoi:
  Unless checked, the resulting number can exceed the expected range
  (CWE-190). If source untrusted, check both minimum and maximum, even if the
  input had no minus sign (large numbers can roll over into negative number;
  consider saving to an unsigned value if that is intended).
	    keyLength=atoi(nextCmd.c_str());
data/stenc-1.0.7/src/main.cpp:172:43:  [2] (integer) atoi:
  Unless checked, the resulting number can exceed the expected range
  (CWE-190). If source untrusted, check both minimum and maximum, even if the
  input had no minus sign (large numbers can roll over into negative number;
  consider saving to an unsigned value if that is intended).
                drvOptions.algorithmIndex=atoi(nextCmd.c_str()); 
data/stenc-1.0.7/src/main.cpp:189:16:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
            kf.open(keyFile.c_str(),ios::trunc);
data/stenc-1.0.7/src/main.cpp:223:13:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
    logFile.open(LOGFILE,ios::app);
data/stenc-1.0.7/src/main.cpp:544:9:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        char buffer[80];
data/stenc-1.0.7/src/scsiencrypt.cpp:67:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char pageCode		[2];
data/stenc-1.0.7/src/scsiencrypt.cpp:68:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char length		[2];
data/stenc-1.0.7/src/scsiencrypt.cpp:99:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char res_bits_2	[8];
data/stenc-1.0.7/src/scsiencrypt.cpp:100:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char keyLength		[2];
data/stenc-1.0.7/src/scsiencrypt.cpp:101:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char keyData		[SSP_KEY_LENGTH];
data/stenc-1.0.7/src/scsiencrypt.cpp:104:10:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
unsigned char
data/stenc-1.0.7/src/scsiencrypt.cpp:210:2:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	char buffer[1024];
data/stenc-1.0.7/src/scsiencrypt.cpp:265:3:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
		memcpy(&buffer[sizeof(SSP_PAGE_SDE)],&kad,kadlen);
data/stenc-1.0.7/src/scsiencrypt.cpp:271:2:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
	memcpy(&buffer,&options,sizeof(SSP_PAGE_SDE));
data/stenc-1.0.7/src/scsiencrypt.cpp:273:11:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	unsigned char spout_sde_command [SSP_SP_CMD_LEN] = {
data/stenc-1.0.7/src/scsiencrypt.cpp:315:2:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
	memcpy(&cmdio.scsi_cdb,cmd_p,cmd_len);
data/stenc-1.0.7/src/scsiencrypt.cpp:339:3:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
		memcpy(&scmdio.scsi_cdb,&scsi_sense_command,sizeof(scsi_sense_command));
data/stenc-1.0.7/src/scsiencrypt.cpp:354:10:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
	sg_fd = open(tapedevice, O_RDONLY);
data/stenc-1.0.7/src/scsiencrypt.cpp:450:2:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
	memcpy(&nbes,buffer,sizeof(SSP_PAGE_NBES));
data/stenc-1.0.7/src/scsiencrypt.cpp:456:2:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
	memcpy(&des,buffer,sizeof(SSP_PAGE_DES));
data/stenc-1.0.7/src/scsiencrypt.cpp:467:17:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
                memcpy(&kad,rawbuff+pos,SSP_KAD_HEAD_LENGTH);
data/stenc-1.0.7/src/scsiencrypt.cpp:472:18:  [2] (buffer) memcpy:
  Does not check for buffer overflows when copying to destination (CWE-120).
  Make sure destination can always hold the source data.
        	        memcpy(&kad.descriptor,rawbuff+pos,kadDesLen);
data/stenc-1.0.7/src/scsiencrypt.cpp:483:20:  [2] (misc) open:
  Check when opening files - can an attacker redirect it (via symlinks),
  force the opening of special file type (e.g., device files), move things
  around to create a race condition, control its ancestors, or change its
  contents? (CWE-362).
       int sg_fd = open(tapeDevice.c_str(), O_RDONLY);
data/stenc-1.0.7/src/scsiencrypt.h:82:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char pageCode		[2]; 
data/stenc-1.0.7/src/scsiencrypt.h:83:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char length		[2];
data/stenc-1.0.7/src/scsiencrypt.h:97:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char keyInstance		[4];
data/stenc-1.0.7/src/scsiencrypt.h:113:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char ASDKCount		[2];
data/stenc-1.0.7/src/scsiencrypt.h:114:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char res_bits_4		[8];
data/stenc-1.0.7/src/scsiencrypt.h:127:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char descriptorLength	[2];
data/stenc-1.0.7/src/scsiencrypt.h:128:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char descriptor		[SSP_DESCRIPTOR_LENGTH]; //will actually be the size of descriptorLength
data/stenc-1.0.7/src/scsiencrypt.h:132:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char pageCode		[2];
data/stenc-1.0.7/src/scsiencrypt.h:133:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char length		[2];
data/stenc-1.0.7/src/scsiencrypt.h:134:11:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	unsigned char buffer		[SSP_PAGE_ALLOCATION];
data/stenc-1.0.7/src/scsiencrypt.h:139:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char pageCode		[2];
data/stenc-1.0.7/src/scsiencrypt.h:140:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char length		[2];
data/stenc-1.0.7/src/scsiencrypt.h:141:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char log_obj_num		[8];
data/stenc-1.0.7/src/scsiencrypt.h:182:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char Version		[1];
data/stenc-1.0.7/src/scsiencrypt.h:196:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char additionalLength	[1];
data/stenc-1.0.7/src/scsiencrypt.h:250:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char vender		[8];
data/stenc-1.0.7/src/scsiencrypt.h:251:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char productID		[16];
data/stenc-1.0.7/src/scsiencrypt.h:252:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char productRev		[4];
data/stenc-1.0.7/src/scsiencrypt.h:253:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char SN			[7];
data/stenc-1.0.7/src/scsiencrypt.h:254:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char venderUnique		[12];
data/stenc-1.0.7/src/scsiencrypt.h:268:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char res_bits_4		[1];
data/stenc-1.0.7/src/scsiencrypt.h:269:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char versionDescriptor	[16];
data/stenc-1.0.7/src/scsiencrypt.h:270:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char res_bits_5		[22];
data/stenc-1.0.7/src/scsiencrypt.h:271:14:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
    unsigned char copyright		[1];																			
data/stenc-1.0.7/src/scsiencrypt.h:296:11:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	unsigned char information	[4];
data/stenc-1.0.7/src/scsiencrypt.h:298:11:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	unsigned char cmdSpecificInfo	[4];
data/stenc-1.0.7/src/scsiencrypt.h:316:18:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
        unsigned char field		[2]; // field pointer 
data/stenc-1.0.7/src/scsiencrypt.h:317:11:  [2] (buffer) char:
  Statically-sized arrays can be improperly restricted, leading to potential
  overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use
  functions that limit length, or ensure that the size is larger than the
  maximum possible length.
	unsigned char addSenseData	[109];
data/stenc-1.0.7/src/main.cpp:188:6:  [1] (access) umask:
  Ensure that umask is given most restrictive possible setting (e.g., 066 or
  077) (CWE-732).
	    umask(077); //make sure that no one else can read the new key file we are creating
data/stenc-1.0.7/src/main.cpp:559:5:  [1] (buffer) getchar:
  Check buffer boundaries if used in a loop including recursive loops
  (CWE-120, CWE-20).
		c=getchar();

ANALYSIS SUMMARY:

Hits = 57
Lines analyzed = 1689 in approximately 0.07 seconds (25876 lines/second)
Physical Source Lines of Code (SLOC) = 1425
Hits@level = [0]   0 [1]   2 [2]  52 [3]   1 [4]   0 [5]   2
Hits@level+ = [0+]  57 [1+]  57 [2+]  55 [3+]   3 [4+]   2 [5+]   2
Hits/KSLOC@level+ = [0+]  40 [1+]  40 [2+] 38.5965 [3+] 2.10526 [4+] 1.40351 [5+] 1.40351
Dot directories skipped = 1 (--followdotdir overrides)
Minimum risk level = 1
Not every hit is necessarily a security vulnerability.
There may be other security vulnerabilities; review your code!
See 'Secure Programming HOWTO'
(https://dwheeler.com/secure-programs) for more information.