summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-03-03 11:43:36 +0000
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2019-03-03 11:43:36 +0000
commit58eceeef12ee7616e83cb4b99c33353803375a15 (patch)
tree6d559686c90d2bdb58fb21a114c33873f29dbb23 /src
parentf392c5a4363cf09e8c0e50a42c46416a09a72c74 (diff)
ecore imf - scim module - fix string handling to stop warnings
so blind use of strncpy was again wrong - it limited to the length of the src not the dest buffer and gcc warnings pointed out this silliness. so instead go back to strcpy with proper length checks before and now it's clear that it's correct and not trying to hide behind strncpy which was wrong.
Diffstat (limited to 'src')
-rw-r--r--src/modules/ecore_imf/scim/scim_imcontext.cpp23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/modules/ecore_imf/scim/scim_imcontext.cpp b/src/modules/ecore_imf/scim/scim_imcontext.cpp
index 404f880d17..993a7d8f37 100644
--- a/src/modules/ecore_imf/scim/scim_imcontext.cpp
+++ b/src/modules/ecore_imf/scim/scim_imcontext.cpp
@@ -358,7 +358,7 @@ find_ic(int id)
358static void 358static void
359feed_key_event(Evas *evas, const char *str, Eina_Bool fake) 359feed_key_event(Evas *evas, const char *str, Eina_Bool fake)
360{ 360{
361 char key_string[128] = {0}; 361 char key_string[128] = { 0 };
362 unsigned int timestamp = 0; 362 unsigned int timestamp = 0;
363 363
364 if (!fake) 364 if (!fake)
@@ -366,15 +366,26 @@ feed_key_event(Evas *evas, const char *str, Eina_Bool fake)
366 366
367 if (strncmp(str, "KeyRelease+", 11) == 0) 367 if (strncmp(str, "KeyRelease+", 11) == 0)
368 { 368 {
369 strncpy(key_string, str + 11, strlen(str)-11); 369 if ((strlen(str) - 11 + 1) > sizeof(key_string))
370 evas_event_feed_key_up(evas, key_string, key_string, NULL, NULL, timestamp, NULL); 370 {
371 fprintf(stderr, "Key string too long: '%s'", str);
372 return;
373 }
374 strcpy(key_string, str + 11);
375 evas_event_feed_key_up(evas, key_string, key_string, NULL, NULL,
376 timestamp, NULL);
371 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_up()...\n"; 377 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_up()...\n";
372 } 378 }
373 else 379 else
374 { 380 {
375 if (strlen(str) + 1 > 128) return; 381 if ((strlen(str) + 1) > sizeof(key_string))
376 strncpy(key_string, str, strlen(str) + 1); 382 {
377 evas_event_feed_key_down(evas, key_string, key_string, NULL, NULL, timestamp, NULL); 383 fprintf(stderr, "Key string too long: '%s'", str);
384 return;
385 }
386 strcpy(key_string, str);
387 evas_event_feed_key_down(evas, key_string, key_string, NULL, NULL,
388 timestamp, NULL);
378 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_down()...\n"; 389 SCIM_DEBUG_FRONTEND(1) << " evas_event_feed_key_down()...\n";
379 } 390 }
380} 391}