Mitigate Baron SameEdit (CVE-2021-3156) vulnerability

rhel 6
format weakness #5

4

Weakness Breakdown


Definition:

A format string exploit occurs when the data of an input string is evaluated as a command by the program. This class of attacks is very similar to buffer overflows since an attacker could execute code, read the stack or cause new behaviors that compromise security. Learn more about format string attacks on OWASP attack index.

Warning code(s):

Potential format string problem.

File Name:

kdemultimedia-4.3.4/libkcompactdisc/wmlib/scsi.c

Context:

The highlighted line of code below is the trigger point of this particular Red Hat Enterprise Linux 6 format weakness.

  *
 * d		Drive structure
 * vendor	Buffer for vendor name (8 bytes + null)
 * model	Buffer for model name (16 bytes + null)
 * rev		Buffer for revision level (4 bytes + null)
 *
 * The above string lengths apply to the SCSI INQUIRY command. The
 * actual WorkMan drive structure reserves 31 bytes + NULL per entry.
 *
 * If the model name begins with "CD-ROM" and zero or more spaces, that will
 * all be stripped off since it's just extra junk to WorkMan.
 */
int
wm_scsi_get_drive_type(struct wm_drive *d)
{
/* removed   unsigned*/
	char *s, *t, buf[36];

	memset(buf, 0, 36);

	wm_lib_message(WM_MSG_CLASS_SCSI | WM_MSG_LEVEL_INFO, "Sending SCSI inquiry command...\n");
	if(sendscsi(d, buf, 36, 1, SCMD_INQUIRY, 0, 0, 0, 36, 0,0,0,0,0,0,0)) {
		sprintf(d->vendor, WM_STR_GENVENDOR);
		sprintf(d->model, WM_STR_GENMODEL);
		sprintf(d->revision, WM_STR_GENREV);
		wm_lib_message(WM_MSG_CLASS_SCSI | WM_MSG_LEVEL_ERROR,
			"SCSI Inquiry command not supported in this context\n");
		return -1;
	}

	wm_lib_message(WM_MSG_CLASS_SCSI | WM_MSG_LEVEL_DEBUG, "sent.\n");

	memcpy(d->vendor, buf + 8, 8);
	d->vendor[8] = '\0';
	memcpy(d->model, buf + 16, 16);
	d->model[16] = '\0';
	memcpy(d->revision, buf + 32, 4);
	d->revision[4] = '\0';
	wm_lib_message(WM_MSG_CLASS_SCSI | WM_MSG_LEVEL_VERB, "SCSI Inquiry result: [%s|%s|%s]\n",
		d->vendor, d->model, d->revision);

	/* Remove "CD-ROM " from the model. */
	if (! strncmp(d->model, "CD-ROM", 6)) {
		s = d->model + 6;
		t = d->model;
		while (*s == ' ' || *s == '\t')
			s++;
		while( (*t++ = *s++) )
			;
	} 

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.