summaryrefslogtreecommitdiff
path: root/src/setup/txt_mouseinput.c
diff options
context:
space:
mode:
authorSimon Howard2014-03-29 21:58:08 -0400
committerSimon Howard2014-03-29 21:58:08 -0400
commit6c24da0dad1477fb0585eefac19349dd60f37c3f (patch)
treeefb7e6886d31f3377b4635f210520d2fa94238bf /src/setup/txt_mouseinput.c
parenteb3a4033c7d6f1d5e042edd5f416bbc257e40975 (diff)
downloadchocolate-doom-6c24da0dad1477fb0585eefac19349dd60f37c3f.tar.gz
chocolate-doom-6c24da0dad1477fb0585eefac19349dd60f37c3f.tar.bz2
chocolate-doom-6c24da0dad1477fb0585eefac19349dd60f37c3f.zip
setup: Eliminate use of unsafe string functions.
Eliminate use of strcpy, strcat, strncpy, and use the new safe alternatives.
Diffstat (limited to 'src/setup/txt_mouseinput.c')
-rw-r--r--src/setup/txt_mouseinput.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/setup/txt_mouseinput.c b/src/setup/txt_mouseinput.c
index 6eee78cd..a69d35b4 100644
--- a/src/setup/txt_mouseinput.c
+++ b/src/setup/txt_mouseinput.c
@@ -24,6 +24,7 @@
#include <string.h>
#include "doomkeys.h"
+#include "m_misc.h"
#include "txt_mouseinput.h"
#include "txt_gui.h"
@@ -75,21 +76,21 @@ static void TXT_MouseInputSizeCalc(TXT_UNCAST_ARG(mouse_input))
mouse_input->widget.h = 1;
}
-static void GetMouseButtonDescription(int button, char *buf)
+static void GetMouseButtonDescription(int button, char *buf, size_t buf_len)
{
switch (button)
{
case 0:
- strcpy(buf, "LEFT");
+ M_StringCopy(buf, "LEFT", buf_len);
break;
case 1:
- strcpy(buf, "RIGHT");
+ M_StringCopy(buf, "RIGHT", buf_len);
break;
case 2:
- strcpy(buf, "MID");
+ M_StringCopy(buf, "MID", buf_len);
break;
default:
- sprintf(buf, "BUTTON #%i", button + 1);
+ snprintf(buf, buf_len, "BUTTON #%i", button + 1);
break;
}
}
@@ -102,11 +103,11 @@ static void TXT_MouseInputDrawer(TXT_UNCAST_ARG(mouse_input))
if (*mouse_input->variable < 0)
{
- strcpy(buf, "(none)");
+ M_StringCopy(buf, "(none)", sizeof(buf));
}
else
{
- GetMouseButtonDescription(*mouse_input->variable, buf);
+ GetMouseButtonDescription(*mouse_input->variable, buf, sizeof(buf));
}
TXT_SetWidgetBG(mouse_input);