Skip to content

Commit c3b6c99

Browse files
committed
Added NOTE about buffer overflow check
1 parent a93e318 commit c3b6c99

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

mig/src/libpam-mig/migauthhandler.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,12 @@ static bool mig_reg_auth_attempt(const unsigned int mode,
445445
MAX_PYCMD_LENGTH - strlen(pycmd));
446446
}
447447
strncat(&pycmd[0], ")", MAX_PYCMD_LENGTH - strlen(pycmd));
448-
/* Execute python command if and only if it didn't overflow */
448+
/* Execute python command if and only if it didn't overflow
449+
* NOTE: Since we can't check if pycmd was truncated by strncat
450+
* or if we actually got a command string length of MAX_PYCMD_LENGTH
451+
* we cap the maximum allowed command string length to MAX_PYCMD_LENGTH-1
452+
* (MAX_PYCMD_LENGTH including the terminator '\0')
453+
*/
449454
if (MAX_PYCMD_LENGTH > strlen(pycmd)) {
450455
pyrun(&pycmd[0]);
451456
PyObject *py_authorized = PyObject_GetAttrString(py_main, "authorized");

0 commit comments

Comments
 (0)