openbsd-ports/x11/wmweather/patches/patch-wmWeather_c
naddy 9cf060dd31 Import of wmWeather 1.31.
Submitted by Peter Stromberg <home@wilfried.net>.

wmWeather monitors local weather conditions (temperature, dew point, pressure,
humidity and wind direction and speed).
2001-01-09 22:13:42 +00:00

109 lines
3.6 KiB
Plaintext

$OpenBSD: patch-wmWeather_c,v 1.1.1.1 2001/01/09 22:13:42 naddy Exp $
--- Src/wmWeather.c.orig Tue May 4 22:20:04 1999
+++ Src/wmWeather.c Tue Jan 9 18:54:59 2001
@@ -229,12 +229,12 @@ char dir[5];
int Year, Month, Day;
int Hours, Mins, Secs;
int UpdateLTHour = 0.0, UpdateLTMin = 0.0, UpdateUTHour, UpdateUTMin;
-long CurrentLocalTime;
+time_t CurrentLocalTime;
double UpdateUT, UpdateLT, UT, LT, DT, hour24();
double jd(), CurrentJD;
-char command[1024], Line[512], FileName[10];
+char command[1024], Line[512], FileName[1024];
int Tens, q, digit, chr;
double Pressure, Temperature, sgn, Humidity, DewPoint, WindChill, val;
double Direction, Speed;
@@ -416,7 +416,7 @@ FILE *fp;
/*
* Read in weather data
*/
- sprintf(FileName, "%s/.wmWeatherReports/%s.dat", getenv("HOME"), StationID);
+ snprintf(FileName, sizeof(FileName), "%s/.wmWeatherReports/%s.dat", getenv("HOME"), StationID);
if ((fp = fopen(FileName, "r")) != NULL){
fgets(Line, 512, fp);
@@ -713,7 +713,7 @@ FILE *fp;
q = 0;
i = (int)(Direction/360.0*16.0 + 0.5);
if (i>15) i = 0;
- strcpy(dir, CompassDirection[i]);
+ strlcpy(dir, CompassDirection[i], sizeof(dir));
len = strlen(dir);
for (j=0; j<len; ++j){
digit = (int)dir[j] - 48;
@@ -816,7 +816,7 @@ UpToDate = 0;
/*
* Execute Perl script to grab the Latest METAR Report
*/
- sprintf(command, "GrabWeather %s &", StationID);
+ snprintf(command, sizeof(command), "GrabWeather %s &", StationID);
system(command);
ForceDownload = 0;
@@ -868,7 +868,7 @@ void ParseCMDLine(int argc, char *argv[]
print_usage();
exit(-1);
}
- strcpy(BackColor, argv[++i]);
+ strlcpy(BackColor, argv[++i], sizeof(BackColor));
} else if (!strcmp(argv[i], "-tc")){
@@ -877,7 +877,7 @@ void ParseCMDLine(int argc, char *argv[]
print_usage();
exit(-1);
}
- strcpy(StationTimeColor, argv[++i]);
+ strlcpy(StationTimeColor, argv[++i], sizeof(StationTimeColor));
} else if (!strcmp(argv[i], "-lc")){
@@ -886,7 +886,7 @@ void ParseCMDLine(int argc, char *argv[]
print_usage();
exit(-1);
}
- strcpy(LabelColor, argv[++i]);
+ strlcpy(LabelColor, argv[++i], sizeof(LabelColor));
} else if (!strcmp(argv[i], "-wgc")){
@@ -895,7 +895,7 @@ void ParseCMDLine(int argc, char *argv[]
print_usage();
exit(-1);
}
- strcpy(WindGustColor, argv[++i]);
+ strlcpy(WindGustColor, argv[++i], sizeof(WindGustColor));
} else if (!strcmp(argv[i], "-dc")){
@@ -904,7 +904,7 @@ void ParseCMDLine(int argc, char *argv[]
print_usage();
exit(-1);
}
- strcpy(DataColor, argv[++i]);
+ strlcpy(DataColor, argv[++i], sizeof(DataColor));
} else if (!strcmp(argv[i], "-beaufort")){
@@ -944,7 +944,7 @@ void ParseCMDLine(int argc, char *argv[]
print_usage();
exit(-1);
}
- strcpy(StationID, StringToUpper(argv[++i]));
+ strlcpy(StationID, StringToUpper(argv[++i]), sizeof(StationID));
} else if (!strcmp(argv[i], "-delay")) {
@@ -1131,7 +1131,7 @@ void ButtonPressEvent(XButtonEvent *xev)
if (GotDoubleClick1) {
GotFirstClick1 = 0;
GotDoubleClick1 = 0;
- sprintf(Command, "xmessage -center -file %s/.wmWeatherReports/%s.TXT &", getenv("HOME"), StationID);
+ snprintf(Command, sizeof(Command), "xmessage -center -file %s/.wmWeatherReports/%s.TXT &", getenv("HOME"), StationID);
system(Command);
}