Skip to content

Commit f989a2f

Browse files
committed
va: validate inputs in vaSetDriverName() before use
Add CHECK_DISPLAY(dpy) before CTX(dpy) to validate the display handle, and add a NULL check for driver_name before calling strlen(). Without these guards, passing NULL for either argument causes a null-pointer dereference instead of returning a proper error status. This aligns vaSetDriverName() with the validation pattern used by other public APIs in va.c. Signed-off-by: Carl.Zhang <carl.zhang@intel.com>
1 parent c57dc62 commit f989a2f

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

va/va.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,9 +627,10 @@ VAStatus vaSetDriverName(
627627
VADriverContextP ctx;
628628
VAStatus vaStatus = VA_STATUS_SUCCESS;
629629
char *override_driver_name = NULL;
630+
CHECK_DISPLAY(dpy);
630631
ctx = CTX(dpy);
631632

632-
if (strlen(driver_name) == 0 || strlen(driver_name) >= 256) {
633+
if (!driver_name || strlen(driver_name) == 0 || strlen(driver_name) >= 256) {
633634
vaStatus = VA_STATUS_ERROR_INVALID_PARAMETER;
634635
va_errorMessage(dpy, "vaSetDriverName returns %s\n",
635636
vaErrorStr(vaStatus));

0 commit comments

Comments
 (0)