[Libva] [PATCH 2/2] Use the strncasecmp instead of strcasecmp to make it more robust

Zhao Yakui yakui.zhao at intel.com
Wed Sep 24 00:13:53 PDT 2014


Signed-off-by: Zhao Yakui <yakui.zhao at intel.com>
---
 src/i965_device_info.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/src/i965_device_info.c b/src/i965_device_info.c
index 4ffba61..b6715a6 100755
--- a/src/i965_device_info.c
+++ b/src/i965_device_info.c
@@ -508,9 +508,14 @@ static void hsw_hw_codec_preinit(VADriverContextP ctx, struct hw_codec_info *cod
 
     found = false;
     list_len = sizeof(hsw_cpu_hook_list) / sizeof(char *);
+    model_len = strlen(model_id);
     for (i = 0; i < list_len; i++) {
         model_ptr = (char *)hsw_cpu_hook_list[i];
-        if (strcasecmp(model_id, model_ptr) == 0) {
+
+        if (strlen(model_ptr) != model_len)
+	    continue;
+
+        if (strncasecmp(model_id, model_ptr, model_len) == 0) {
             found = true;
             break;
 	}
-- 
1.7.10.1



More information about the Libva mailing list