diff options
author | Elaine Wang <elaine.wang@intel.com> | 2010-12-30 15:28:19 +0800 |
---|---|---|
committer | Elaine Wang <elaine.wang@intel.com> | 2010-12-30 15:28:19 +0800 |
commit | 4c1e640b971ddafe05965397078331ffa89824f2 (patch) | |
tree | 8f3cd7d865842e082ce31b6feb1bab6add87021c | |
parent | a4a8b70738e87f86fcaaeb9f23730f01457df1b6 (diff) |
Fix klocwork critical issues. Use strnlen and snprintf instead of strlen and sprintf.
Signed-off-by: Elaine Wang <elaine.wang@intel.com>
-rw-r--r-- | va/va_trace.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/va/va_trace.c b/va/va_trace.c index 656ada9..1ec7f9b 100644 --- a/va/va_trace.c +++ b/va/va_trace.c @@ -157,8 +157,12 @@ void va_TraceInit(VADisplay dpy) if (va_parseConfig("LIBVA_TRACE", &env_value[0]) == 0) { trace_flag = 1; - - sprintf(env_value+strlen(env_value), ".%d.%d", trace_index, suffix); + + /*Check if there is still room for suffix .%d.%d*/ + if (strnlen(env_value, 1024) < (1024 - 8)) + snprintf(env_value+strnlen(env_value, 1024), + (1025 - 8 - strnlen(env_value, 1024)), + ".%d.%d", trace_index, suffix); tmp = fopen(env_value, "w"); if (tmp) { @@ -189,7 +193,10 @@ void va_TraceInit(VADisplay dpy) /* per-context setting */ if (va_parseConfig("LIBVA_TRACE_CODEDBUF", &env_value[0]) == 0) { - sprintf(env_value+strlen(env_value), ".%d.%d", trace_index, suffix); + if (strnlen(env_value, 1024) < (1024 - 8)) + snprintf(env_value+strnlen(env_value, 1024), + (1025 - 8 - strnlen(env_value, 1024)), + ".%d.%d", trace_index, suffix); tmp = fopen(env_value, "w"); @@ -205,7 +212,7 @@ void va_TraceInit(VADisplay dpy) } if (va_parseConfig("LIBVA_TRACE_SURFACE", &env_value[0]) == 0) { - sprintf(env_value+strlen(env_value), ".%d.%d", trace_index, suffix); + sprintf(env_value+strnlen(env_value, 1024), ".%d.%d", trace_index, suffix); tmp = fopen(env_value, "w"); |