alpine 3.7
integer weakness #8


Weakness Breakdown


An integer overflow occurs when the answer to an arithmetic operation exceeds the maximum size of the integer type used to store it. The resulting value will appear to have wrapped around the maximum value and started again at the minimum value. This would look like a clock that represents 13:00 by pointing at 1:00. An attacker can use an integer overflow during a buffer length calculation, which results in the allocated buffer being too small to hold the data copied into it, thus causing a buffer overflow.

Warning code(s):

Unless checked, the resulting number can exceed the expected range.

File Name:



The highlighted line of code below is the trigger point of this particular Alpine 3.7 integer weakness.

 		if(!*p){ _verbose_handler(NULL,"date ended after month??",raw); return 0; }
		// process year
		unixtime.tm_year = atoi(p)-1900;

		PRINT_DEBUG(NULL,"ingres_date: parsed date day=%d mon=%d yr=%d\n",
					unixtime.tm_mday, unixtime.tm_mon, unixtime.tm_year);

		// skip space following date
		while(*p == ' ')

		// Ingres does not generate a time by itself, it's always preceded by a date.
		if(isdigit(*p)){ // time is present
			// process hours
			unixtime.tm_hour = atoi(p);
			if(!*p){ _verbose_handler(NULL,"time ended after hour??",raw); return 0; }
			++p; // skip separator

			// process minutes
			unixtime.tm_min = atoi(p);
			if(!*p){ _verbose_handler(NULL,"time ended after minute??",raw); return 0; }
			++p; // skip separator

			// process seconds
			unixtime.tm_sec = atoi(p); 
			PRINT_DEBUG(NULL,"ingres_date: parsed time %02d:%02d:%02d\n",
						unixtime.tm_hour, unixtime.tm_min, unixtime.tm_sec);
			/* check for a timezone suffix */
			//while(isdigit(*p) || *p == ' ')
			//	++p;
		}else if(*p)
			_verbose_handler(NULL,"bad time: '%s'",p);

		return timegm(&unixtime);
		_verbose_handler(NULL,"bad date: '%s'",raw);
	return 0;

void ingres_classify_field(IIAPI_DESCRIPTOR *ds, unsigned short *type, unsigned int *attribs) {
	*type = 0; 

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.