fedora 23
buffer weakness #31

5

Weakness Breakdown


Definition:

Buffer overflows are one of the most well-known software vulnerabilities. Even though most developers know what buffer overflows are, attacks against the vulnerabilities are common in both legacy and newer applications. A classic buffer overflow exploit begins with the attacker sending data to a program, which it then stores in an undersized stack buffer. Besides stack buffer overflows, other kinds of buffer overflows include heap overflows, off-by-one errors and many others. Learn more about buffer overflows on OWASP attack index.

Warning code(s):

Does not check for buffer overflows.

File Name:

glob2-0.9.4.4/src/Utilities.cpp

Context:

The highlighted line of code below is the trigger point of this particular Fedora 23 buffer weakness.

 		staticCounter=(staticCounter+1)&0x7;
		Uint32 ip=SDL_SwapBE32(nip);
		snprintf(staticStringIP[staticCounter], 128, "%d.%d.%d.%d", ((ip>>24)&0xFF), ((ip>>16)&0xFF), ((ip>>8)&0xFF), (ip&0xFF));
		staticStringIP[staticCounter][127]=0;
		return staticStringIP[staticCounter];
	}
	char *stringIP(Uint32 host, Uint16 port)
	{
		staticCounter=(staticCounter+1)&0x7;
		Uint32 ip=SDL_SwapBE32(host);
		snprintf(staticStringIP[staticCounter], 128, "%d.%d.%d.%d:%d", ((ip>>24)&0xFF), ((ip>>16)&0xFF), ((ip>>8)&0xFF), (ip&0xFF), SDL_SwapBE16(port));
		staticStringIP[staticCounter][127]=0;
		return staticStringIP[staticCounter];
	}
	
	char *stringIP(IPaddress nip)
	{
		staticCounter=(staticCounter+1)&0x7;
		Uint32 ip=SDL_SwapBE32(nip.host);
		snprintf(staticStringIP[staticCounter], 128, "%d.%d.%d.%d:%d", ((ip>>24)&0xFF), ((ip>>16)&0xFF), ((ip>>8)&0xFF), (ip&0xFF), SDL_SwapBE16(nip.port));
		staticStringIP[staticCounter][127]=0;
		return staticStringIP[staticCounter];
	}

	char *gets(char *dest, int size, GAGCore::InputStream *stream)
	{
		int i;
		for (i=0;i<size-1;i++)
		{
			char c;
			stream->read(&c, 1, "");
			if (stream->isEndOfStream())
				return NULL;
			switch (c)
			{
			case '\n':
			case '\r':
			case 0:
				dest[i]=0;
				return dest;
			default:
				dest[i]=c;
			}
		}
		dest[i]=0;
		return dest;
	}

	void streamprintf(GAGCore::OutputStream *stream, const char *format, ...)
	{ 

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.