Commit d03ab1de authored by Alan Coopersmith's avatar Alan Coopersmith Committed by Ulrich Sibiller

ximcp/imRm.c: convert sprintf calls to snprintf

parent a1b0fdb2
...@@ -75,8 +75,10 @@ _XimSetProtoResource(im) ...@@ -75,8 +75,10 @@ _XimSetProtoResource(im)
{ {
char res_name_buf[256]; char res_name_buf[256];
char* res_name; char* res_name;
size_t res_name_len;
char res_class_buf[256]; char res_class_buf[256];
char* res_class; char* res_class;
size_t res_class_len;
char* str_type; char* str_type;
XrmValue value; XrmValue value;
XIMStyle preedit_style = 0; XIMStyle preedit_style = 0;
...@@ -90,17 +92,31 @@ _XimSetProtoResource(im) ...@@ -90,17 +92,31 @@ _XimSetProtoResource(im)
if (!im->core.rdb) if (!im->core.rdb)
return; return;
if (strlen (im->core.res_name) < 200) res_name = res_name_buf; res_name_len = strlen (im->core.res_name);
else res_name = Xmalloc (strlen (im->core.res_name) + 50); if (res_name_len < 200) {
if (strlen (im->core.res_class) < 200) res_class = res_class_buf; res_name = res_name_buf;
else res_class = Xmalloc (strlen (im->core.res_class) + 50); 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 */ /* 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 ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot, im->core.res_name != NULL ? dotximdot : ximdot,
"useAuth"); "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 ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot, im->core.res_class != NULL ? dotXimdot : Ximdot,
"UseAuth"); "UseAuth");
...@@ -111,11 +127,11 @@ _XimSetProtoResource(im) ...@@ -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 ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot, im->core.res_name != NULL ? dotximdot : ximdot,
"delaybinding"); "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 ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot, im->core.res_class != NULL ? dotXimdot : Ximdot,
"Delaybinding"); "Delaybinding");
...@@ -126,11 +142,11 @@ _XimSetProtoResource(im) ...@@ -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 ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot, im->core.res_name != NULL ? dotximdot : ximdot,
"reconnect"); "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 ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot, im->core.res_class != NULL ? dotXimdot : Ximdot,
"Reconnect"); "Reconnect");
...@@ -147,11 +163,11 @@ _XimSetProtoResource(im) ...@@ -147,11 +163,11 @@ _XimSetProtoResource(im)
return; 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 ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot, im->core.res_name != NULL ? dotximdot : ximdot,
"preeditDefaultStyle"); "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 ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot, im->core.res_class != NULL ? dotXimdot : Ximdot,
"PreeditDefaultStyle"); "PreeditDefaultStyle");
...@@ -170,11 +186,11 @@ _XimSetProtoResource(im) ...@@ -170,11 +186,11 @@ _XimSetProtoResource(im)
if(!preedit_style) if(!preedit_style)
preedit_style = XIMPreeditNothing; 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 ? im->core.res_name : "*",
im->core.res_name != NULL ? dotximdot : ximdot, im->core.res_name != NULL ? dotximdot : ximdot,
"statusDefaultStyle"); "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 ? im->core.res_class : "*",
im->core.res_class != NULL ? dotXimdot : Ximdot, im->core.res_class != NULL ? dotXimdot : Ximdot,
"StatusDefaultStyle"); "StatusDefaultStyle");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment