1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
|
Author: Ulf Härnhammar <Ulf.Harnhammar.9485@student.uu.se>
Description: Fixes buffer overflows while loading the config file.
Bug-Debian: http://bugs.debian.org/290822
--- a/src/KommandoZeilenParameter.cpp
+++ b/src/KommandoZeilenParameter.cpp
@@ -8,8 +8,8 @@
void SchreibeKonfiguration(){
FILE *f;
#ifndef _WIN32
- char dateiname[40];
- sprintf(dateiname,"%s/.BillardGL.conf.v7",getenv("HOME"));
+ char dateiname[512];
+ snprintf(dateiname,sizeof(dateiname),"%s/.BillardGL.conf.v7",getenv("HOME"));
f=fopen(dateiname,"w+");
#endif
#ifdef _WIN32
@@ -65,8 +65,8 @@
void LeseKonfiguration(){
FILE *f;
#ifndef _WIN32
- char dateiname[40];
- sprintf(dateiname,"%s/.BillardGL.conf.v7",getenv("HOME"));
+ char dateiname[512];
+ snprintf(dateiname,sizeof(dateiname),"%s/.BillardGL.conf.v7",getenv("HOME"));
f=fopen(dateiname,"r");
#endif
#ifdef _WIN32
@@ -95,9 +95,9 @@
fscanf(f,"%i",&GrueneLampe);
fscanf(f,"%f",&EffektLautstaerke);
fscanf(f,"%f",&MusikLautstaerke);
- fscanf(f,"%s",Spieler1temp);
- fscanf(f,"%s",Spieler2temp);
- fscanf(f,"%s",NetzwerkSpielertemp);
+ fscanf(f,"%9s",Spieler1temp);
+ fscanf(f,"%9s",Spieler2temp);
+ fscanf(f,"%9s",NetzwerkSpielertemp);
for (int i=0;i<10;i++) {
if (Spieler1temp[i]=='%') {
Spieler1[i]=' ';
|