diff options
author | Alan Coopersmith <alan.coopersmith@oracle.com> | 2013-08-09 23:30:30 -0700 |
---|---|---|
committer | Ulrich Sibiller <uli42@gmx.de> | 2016-10-19 21:40:28 +0200 |
commit | d03ab1de0b68290291e2b74834b0c7dbe8b6df21 (patch) | |
tree | 14cc5eea22d69296417ed6bb603644d765dd0db5 /nx-X11/lib/X11/imRm.c | |
parent | a1b0fdb2c9852c48ede8e3bc2a7049d707188fd1 (diff) | |
download | nx-libs-d03ab1de0b68290291e2b74834b0c7dbe8b6df21.tar.gz nx-libs-d03ab1de0b68290291e2b74834b0c7dbe8b6df21.tar.bz2 nx-libs-d03ab1de0b68290291e2b74834b0c7dbe8b6df21.zip |
ximcp/imRm.c: convert sprintf calls to snprintf
Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Matthieu Herrb <matthieu.herrb@laas.fr>
Backported-to-NX-by: Ulrich Sibiller <uli42@gmx.de>
Diffstat (limited to 'nx-X11/lib/X11/imRm.c')
-rw-r--r-- | nx-X11/lib/X11/imRm.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/nx-X11/lib/X11/imRm.c b/nx-X11/lib/X11/imRm.c index 34c9bfa35..a7565d94b 100644 --- a/nx-X11/lib/X11/imRm.c +++ b/nx-X11/lib/X11/imRm.c @@ -75,8 +75,10 @@ _XimSetProtoResource(im) { char res_name_buf[256]; char* res_name; + size_t res_name_len; char res_class_buf[256]; char* res_class; + size_t res_class_len; char* str_type; XrmValue value; XIMStyle preedit_style = 0; @@ -90,17 +92,31 @@ _XimSetProtoResource(im) if (!im->core.rdb) return; - if (strlen (im->core.res_name) < 200) res_name = res_name_buf; - else res_name = Xmalloc (strlen (im->core.res_name) + 50); - if (strlen (im->core.res_class) < 200) res_class = res_class_buf; - else res_class = Xmalloc (strlen (im->core.res_class) + 50); + res_name_len = strlen (im->core.res_name); + if (res_name_len < 200) { + res_name = res_name_buf; + res_name_len = sizeof(res_name_buf); + } + else { + res_name_len += 50; + res_name = Xmalloc (res_name_len); + } + res_class_len = strlen (im->core.res_class); + if (res_class_len < 200) { + res_class = res_class_buf; + res_class_len = sizeof(res_class_buf); + } + else { + res_class_len += 50; + res_class = Xmalloc (res_class_len); + } /* pretend malloc always works */ - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "useAuth"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "UseAuth"); @@ -111,11 +127,11 @@ _XimSetProtoResource(im) } } - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "delaybinding"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "Delaybinding"); @@ -126,11 +142,11 @@ _XimSetProtoResource(im) } } - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "reconnect"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "Reconnect"); @@ -147,11 +163,11 @@ _XimSetProtoResource(im) return; } - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "preeditDefaultStyle"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "PreeditDefaultStyle"); @@ -170,11 +186,11 @@ _XimSetProtoResource(im) if(!preedit_style) preedit_style = XIMPreeditNothing; - (void) sprintf (res_name, "%s%s%s", + (void) snprintf (res_name, res_name_len, "%s%s%s", im->core.res_name != NULL ? im->core.res_name : "*", im->core.res_name != NULL ? dotximdot : ximdot, "statusDefaultStyle"); - (void) sprintf (res_class, "%s%s%s", + (void) snprintf (res_class, res_class_len, "%s%s%s", im->core.res_class != NULL ? im->core.res_class : "*", im->core.res_class != NULL ? dotXimdot : Ximdot, "StatusDefaultStyle"); |