niash.c: Add argument screening to sane_control_option

This prevents access to non-existing array elements as well as
potential NULL dereferences.

Fixes #315132.
merge-requests/1/head
Olaf Meeuwissen 2015-09-14 18:24:39 +09:00
rodzic 26572efbd1
commit db83bf44de
1 zmienionych plików z 13 dodań i 0 usunięć

Wyświetl plik

@ -995,6 +995,19 @@ sane_control_option (SANE_Handle h, SANE_Int n, SANE_Action Action,
DBG (DBG_MSG, "sane_control_option: option %d, action %d\n", n, Action);
if ((n < optCount) || (n >= optLast))
{
return SANE_STATUS_UNSUPPORTED;
}
if (Action == SANE_ACTION_GET_VALUE || Action == SANE_ACTION_SET_VALUE)
{
if (pVal == NULL)
{
return SANE_STATUS_INVAL;
}
}
s = (TScanner *) h;
info = 0;