From d3408e38b01e12ab5f7dd5a2911531fe6d87c9d5 Mon Sep 17 00:00:00 2001
From: Allanis <allanis@saracraft.net>
Date: Sun, 20 Jul 2014 20:53:14 +0100
Subject: [PATCH] [Change] Changed vsprintf to vsnprintf to be safe.

---
 src/dialogue.c |  8 ++++----
 src/font.c     | 12 ++++++------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/src/dialogue.c b/src/dialogue.c
index 84900aa..8743b5a 100644
--- a/src/dialogue.c
+++ b/src/dialogue.c
@@ -61,7 +61,7 @@ void dialogue_alert(const char* fmt, ...) {
   if(fmt == NULL) return;
   else { /* Get the message. */
     va_start(ap, fmt);
-    vsprintf(msg, fmt, ap);
+    vsnprintf(msg, 512, fmt, ap);
     va_end(ap);
   }
 
@@ -142,7 +142,7 @@ void dialogue_msg(char* caption, const char* fmt, ...) {
   if(fmt == NULL) return;
   else {
     va_start(ap, fmt);
-    vsprintf(msg, fmt, ap);
+    vsnprintf(msg, 4096, fmt, ap);
     va_end(ap);
   }
 
@@ -185,7 +185,7 @@ int dialogue_YesNo(char* caption, const char* fmt, ...) {
   if(fmt == NULL) return -1;
   else { /* Get the message. */
     va_start(ap, fmt);
-    vsprintf(msg, fmt, ap);
+    vsnprintf(msg, 4096, fmt, ap);
     va_end(ap);
   }
 
@@ -252,7 +252,7 @@ char* dialogue_input(char* title, int min, int max, const char* fmt, ...) {
   if(fmt == NULL) return NULL;
   else { /* Get the message. */
     va_start(ap, fmt);
-    vsprintf(msg, fmt, ap);
+    vsnprintf(msg, 512, fmt, ap);
     va_end(ap);
   }
 
diff --git a/src/font.c b/src/font.c
index 18e9a5f..280cfe6 100644
--- a/src/font.c
+++ b/src/font.c
@@ -131,7 +131,7 @@ void gl_print(const glFont* ft_font, const double x, const double y,
   else {
     /* convert the symbols to text. */
     va_start(ap, fmt);
-    vsprintf(txt, fmt, ap);
+    vsnprintf(txt, 256, fmt, ap);
     va_end(ap);
   }
 
@@ -180,7 +180,7 @@ int gl_printMax(const glFont* ft_font, const int max,
   else {
     /* convert the symbols to text. */
     va_start(ap, fmt);
-    vsprintf(txt, fmt, ap);
+    vsnprintf(txt, 256, fmt, ap);
     va_end(ap);
   }
 
@@ -239,7 +239,7 @@ int gl_printMid(const glFont* ft_font, const int width, double x, const double y
   else {
     /* convert the symbols to text. */
     va_start(ap, fmt);
-    vsprintf(txt, fmt, ap);
+    vsnprintf(txt, 256, fmt, ap);
     va_end(ap);
   }
 
@@ -301,7 +301,7 @@ int gl_printText(const glFont* ft_font, const int width, const int height,
   else {
     /* Convert the symbols to text. */
     va_start(ap, fmt);
-    vsprintf(txt, fmt, ap);
+    vsnprintf(txt, 4096, fmt, ap);
     va_end(ap);
   }
   bx -= (double)SCREEN_W/2.;
@@ -360,7 +360,7 @@ int gl_printWidth(const glFont* ft_font, const char* fmt, ...) {
   else {
     /* Convert the symbols to text. */
     va_start(ap, fmt);
-    vsprintf(txt, fmt, ap);
+    vsnprintf(txt, 256, fmt, ap);
     va_end(ap);
   }
 
@@ -396,7 +396,7 @@ int gl_printHeight(const glFont* ft_font, const int width,
   else {
     /* Convert the symbols to text. */
     va_start(ap, fmt);
-    vsprintf(txt, fmt, ap);
+    vsnprintf(txt, 1024, fmt, ap);
     va_end(ap);
   }