alpine 3.8
integer weakness #2

2

Weakness Breakdown


Definition:

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:

abook/src/abook-0.6.1/abook.h

Context:

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

 
#define MAIN_HELPLINE        N_("q:quit  ?:help  a:add  r:remove")

#define Y_STATUSLINE   	(LINES - 2)

#define MIN_LINES	20
#define MIN_COLS	70

#define DEFAULT_UMASK	066
#define DIR_IN_HOME	".abook"
#define DATAFILE	"addressbook"

#define RCFILE		"abookrc"

#define QUIT_SAVE	1
#define QUIT_DONTSAVE	0

/*
 * some "abookwide" useful macros
 */

#define hide_cursor()	curs_set(0)
#define show_cursor()	curs_set(1)

#define safe_atoi(X)    ((X == NULL) ? 0 : atoi(X))
#define safe_str(X)	((X == NULL) ? "" : X)

#ifndef min
#       define min(x,y) (((x)<(y)) ? (x):(y))
#endif

#ifndef max
#       define max(x,y) (((x)>(y)) ? (x):(y))
#endif

#define ISSPACE(c)	isspace((unsigned char)c)

#define SKIPWS(c)	while(*(c) && ISSPACE(*(c))) c++
#define SKIPNONWS(c)	while(*(c) && ! ISSPACE(*(c))) c++

#ifndef DEBUG
#	define NDEBUG	1
#else
#	undef NDEBUG
#endif

#endif 

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.