alpine 3.8
buffer weakness #30

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

Easily used incorrectly.

File Name:

krb5/src/krb5-1.15.4/src/windows/leash/Leash.cpp

Context:

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

 {
    if (m_hKrb5DLL
////
#ifndef NO_KRB4
	&& !m_hKrb4DLL
#endif
	)
	{ // hold krb.con where krb5.ini is located
		CHAR krbConFile[MAX_PATH]="";
	    //strcpy(krbConFile, CLeashApp::m_krbv5_profile->first_file->filename);
        if (GetProfileFile(krbConFile, sizeof(krbConFile)))
        {
		    GetWindowsDirectory(krbConFile,sizeof(krbConFile));
            krbConFile[MAX_PATH-1] = '\0';
			strncat(krbConFile,"\\KRB5.INI",sizeof(krbConFile)-strlen(krbConFile)-1);
            krbConFile[MAX_PATH-1] = '\0';
        }

		LPSTR pFind = strrchr(krbConFile, '\\');
		if (pFind)
		{
			*pFind = 0;
			strncat(krbConFile, "\\",MAX_PATH-1);
            krbConFile[MAX_PATH-1] = '\0';
			strncat(krbConFile, KRB_FILE,MAX_PATH-1);
            krbConFile[MAX_PATH-1] = '\0';
		}
		else
		  ASSERT(0);

		strncpy(confname, krbConFile, szConfname);
        confname[szConfname-1] = '\0';
	}
////
#ifndef NO_KRB4
	else if (m_hKrb4DLL)
	{
        unsigned int size = szConfname;
        memset(confname, '\0', szConfname);
		if (!pkrb_get_krbconf2(confname, &size))
		{ // Error has happened
		    GetWindowsDirectory(confname,szConfname);
            confname[szConfname-1] = '\0';
			strncat(confname, "\\",szConfname);
            confname[szConfname-1] = '\0';
			strncat(confname,KRB_FILE,szConfname);
            confname[szConfname-1] = '\0';
		}
	}
#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.