fedora 25
format weakness #7

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):

If format strings can be influenced by an attacker, they can be exploited.

File Name:

atril-1.18.2/cut-n-paste/synctex/synctex_parser.c

Context:

The highlighted line of code below is the trigger point of this particular Fedora 25 format weakness.

 	if (NULL == updater) {
		_synctex_error("!  synctex_updater_new_with_file: malloc problem");
		return NULL;
	}
	if (_synctex_open(output,build_directory,&synctex,&SYNCTEX_FILE,synctex_ADD_QUOTES,&io_mode)
		&& _synctex_open(output,build_directory,&synctex,&SYNCTEX_FILE,synctex_DONT_ADD_QUOTES,&io_mode)) {
return_on_error:
		free(updater);
        updater = NULL;
		return NULL;
	}
	/*  OK, the file exists, we close it and reopen it with the correct mode.
     *  The receiver is now the owner of the "synctex" variable. */
	gzclose(SYNCTEX_FILE);
	SYNCTEX_FILE = NULL;
	SYNCTEX_NO_GZ = (io_mode&synctex_io_gz_mask)?synctex_NO:synctex_YES;
    mode = _synctex_get_io_mode_name(io_mode|synctex_io_append_mask);/* either "a" or "ab", depending on the file extension */
	if (SYNCTEX_NO_GZ) {
		if (NULL == (SYNCTEX_FILE = (void *)fopen(synctex,mode))) {
no_write_error:
			_synctex_error("!  synctex_updater_new_with_file: Can't append to %s",synctex);
			free(synctex);
			goto return_on_error;
		}
		updater->fprintf = (synctex_fprintf_t)(&fprintf);
	} else {
		if (NULL == (SYNCTEX_FILE = (void *)gzopen(synctex,mode))) {
			goto no_write_error;
		}
		updater->fprintf = (synctex_fprintf_t)(&gzprintf);
	}
	printf("SyncTeX: updating %s...",synctex);
	free(synctex);
	return updater;
}


void synctex_updater_append_magnification(synctex_updater_t updater, char * magnification){
	if (NULL==updater) {
		return;
	}
	if (magnification && strlen(magnification)) {
		updater->length += SYNCTEX_fprintf(SYNCTEX_FILE,"Magnification:%s\n",magnification);
	}
}

void synctex_updater_append_x_offset(synctex_updater_t updater, char * x_offset){
	if (NULL==updater) {
		return;
	} 

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.