strn cleanup.
authorGwyn Ciesla <limburgher@gmail.com>
Mon, 27 Nov 2017 23:28:32 +0000 (17:28 -0600)
committerGwyn Ciesla <limburgher@gmail.com>
Mon, 27 Nov 2017 23:28:32 +0000 (17:28 -0600)
main.cpp
mishaps.cpp
powerup.cpp

index e13909a..72ffc83 100644 (file)
--- a/main.cpp
+++ b/main.cpp
@@ -48,7 +48,7 @@ const int landershotmax = 10;
 const int landermax = 12;
 const int crawlermax = 6;
 const int missilemax = 3;
-const float version = 1.13;
+const float version = 1.14;
 
 int score;
 int lives;
@@ -538,7 +538,7 @@ int main(int argc, char *argv[]){
   char filename[250];
   strcpy (filename, "/.curblaster_scores");
   char home[250];
-  strcpy(home, getenv("HOME"));
+  strncpy(home, getenv("HOME"), 230);
   
   strncat(home, filename, 20);
   
index 3b2fd45..26507fa 100644 (file)
@@ -83,7 +83,7 @@ int life_loss(int lives, int score){
     char outstring[50];
     strcpy (filename, "/.curblaster_scores");
     char home[250];
-    strcpy(home, getenv("HOME"));
+    strncpy(home, getenv("HOME"), 230);
     
     strncat(home, filename, 20);
     
index aa5ef70..56bf36b 100644 (file)
@@ -21,25 +21,25 @@ game_object powerup_init(game_object powerup, game_object object){
   int fodder = rand()%1500;
 
   if(fodder>=1200){
-    strcpy (powerup.line0, "M");
+    strncpy(powerup.line0, "M", 1);
   };
   if(fodder>=1000&&fodder<1200){
-    strcpy (powerup.line0, "T");
+    strncpy(powerup.line0, "T", 1);
   };
   if(fodder>=800&&fodder<1000){
-    strcpy (powerup.line0, "S");
+    strncpy(powerup.line0, "S", 1);
   };
   if(fodder>=600&&fodder<800){
-    strcpy (powerup.line0, "K");
+    strncpy(powerup.line0, "K", 1);
   };
   if(fodder>=400&&fodder<600){
-    strcpy (powerup.line0, "L");
+    strncpy(powerup.line0, "L", 1);
   };
   if(fodder>=200&&fodder<400){
-    strcpy (powerup.line0, "B");
+    strncpy(powerup.line0, "B", 1);
   };
   if(fodder<200){
-    strcpy (powerup.line0, "Z");
+    strncpy(powerup.line0, "Z", 1);
   };
   
   return powerup;