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