fedora 25
format weakness #6

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.

 	}
	return NULL;
}

#	ifdef SYNCTEX_NOTHING
#       pragma mark -
#       pragma mark Updater
#   endif

typedef int (*synctex_fprintf_t)(void *, const char * , ...); /*  print formatted to either FILE *  or gzFile */

#   define SYNCTEX_BITS_PER_BYTE 8

struct __synctex_updater_t {
    gzFile file;                /*  the foo.synctex or foo.synctex.gz I/O identifier  */
    synctex_fprintf_t fprintf;  /*  either fprintf or gzprintf */
    int length;                 /*  the number of chars appended */
    struct _flags {
        unsigned int no_gz:1;   /*  Whether zlib is used or not */
        unsigned int reserved:SYNCTEX_BITS_PER_BYTE*sizeof(int)-1; /*  Align */
	} flags;
};
#   define SYNCTEX_FILE updater->file
#   define SYNCTEX_NO_GZ ((updater->flags).no_gz)
#   define SYNCTEX_fprintf (*(updater->fprintf))

synctex_updater_t synctex_updater_new_with_output_file(const char * output, const char * build_directory) {
	synctex_updater_t updater = NULL;
	char * synctex = NULL;
	synctex_io_mode_t io_mode = 0;
	const char * mode = NULL;
	/*  prepare the updater, the memory is the only one dynamically allocated */
	updater = (synctex_updater_t)_synctex_malloc(sizeof(synctex_updater_t));
	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 */ 

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.