fedora 24
buffer weakness #22

5

Weakness Breakdown


Definition:

Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Easily used incorrectly.

File Name:

dt.v18.32/libscsi.c

Context:

The highlighted line of code below is the trigger point of this particular Fedora 24 buffer weakness.

     if (status != SUCCESS) {
	return(IDT_NONE);
    }

    if ( (idt == IDT_BOTHIDS) || (idt == IDT_DEVICEID) ) {
	/*
	 * The preferred ID, is from Inquiry Page 0x83 (Device ID).
	 */
	if (*identifier = GetDeviceIdentifier(fd, dsf, debug, errlog,
					      NULL, NULL, inquiry, timeout)) {
	    return(IDT_DEVICEID);
	}
    }

    if ( (idt == IDT_BOTHIDS) || (idt == IDT_SERIALID) ) {
	/*
	 * The less preferred WWID, is the serial number prepended with
	 * the vendor and product names to attempt uniqueness.
	 */
	if (serial_number = GetSerialNumber(fd, dsf, debug, errlog,
					    NULL, NULL, inquiry, timeout)) {
	    *identifier = Malloc(MAX_INQ_LEN + INQ_VID_LEN + INQ_PID_LEN);
	    *identifier[0] = '\0';
	    (void)strncpy(*identifier, (char *)inquiry->inq_vid, INQ_VID_LEN);
	    (void)strncat(*identifier, (char *)inquiry->inq_pid, INQ_PID_LEN);
	    (void)strcat(*identifier, serial_number);
	    (void)free(serial_number);
	    return(IDT_SERIALID);
	}
    }
    return(IDT_NONE);
}

/* ======================================================================== */

/*
 * Declarations/Definitions for Read Capacity(10) Command:
 */
#define ReadCapacity10Name	"Read Capacity(10)"
#define ReadCapacity10Opcode	0x25
#define ReadCapacity10CdbSize	10 
#define ReadCapacity10Timeout	(30 * MSECS)

typedef struct ReadCapacity10_CDB {
    uint8_t opcode;
    uint8_t reserved_byte1;
    uint8_t lba[4];
    uint8_t reserved_byte7;
    uint8_t reserved1_byte8;
#if defined(_BITFIELDS_LOW_TO_HIGH_) 

The registered trademark Linux® is used pursuant to a sublicense from the Linux Foundation, the exclusive licensee of Linus Torvalds, owner of the mark on a world­wide basis.