Sisyphus repository
Last update: 1 october 2023 | SRPMs: 18631 | Visits: 37039479
en ru br
ALT Linux repos
S:0.04-alt4
5.0: 0.04-alt2
4.1: 0.04-alt2
4.0: 0.04-alt2

Group :: Graphical desktop/Window Maker
RPM: wmhdaps

 Main   Changelog   Spec   Patches   Sources   Download   Gear   Bugs and FR  Repocop 

Patch: wmhdaps-0.04-alt4.patch
Download


 wmhdaps/wmhdaps.c |   42 ++++++++++++++++++++++++++++++++++--------
 1 files changed, 34 insertions(+), 8 deletions(-)
diff --git a/wmhdaps/wmhdaps.c b/wmhdaps/wmhdaps.c
index b555b87..ca2d469 100644
--- a/wmhdaps/wmhdaps.c
+++ b/wmhdaps/wmhdaps.c
@@ -47,6 +47,7 @@
 #include <unistd.h>
 #include <ctype.h>
 #include <math.h>
+#include <errno.h>
 
 #include <sys/wait.h>
 #include <sys/stat.h>
@@ -318,7 +319,7 @@ int analyze(int x, int y, double unow, double threshold, int *veloc_percent, int
 	double udelta, x_delta, y_delta, x_veloc, y_veloc, x_accel, y_accel;
 	double veloc_sqr, accel_sqr, avg_veloc_sqr;
 	double exp_weight;
-	char reason[3];
+	char reason[4];
 	int ret = 0;
 	int verbose = 0;
 	
@@ -436,6 +437,7 @@ int main(int argc, char **argv)
 #else
 	char device[256] = "ad0";
 #endif /* !defined(FREEBSD) */
+	int x = 0, y = 0;
 
 	pname = strrchr(argv[0], '/');
 	if (pname == NULL) pname = argv[0];
@@ -509,7 +511,6 @@ int main(int argc, char **argv)
 	while (1)
 	{
 		double unow = get_utime(); /* microsec */
-		int x, y;
 		int ret, call_again=1, protected;
 		static int veloc_percent=0, accel_percent=0, avg_veloc_percent=0;
 
@@ -1208,7 +1209,11 @@ int loadobj(char *filename) {
 		exit(0);
 	}
 
-	fscanf(fp,"%s",tmp);
+	if (fscanf(fp,"%s",tmp) != 1) {
+		printf("\nError in objectfile: %s\n\n", strerror(errno));
+		fclose(fp);
+		exit(0);
+	}
 	
 	if (strcmp(tmp,"WMCUBE_COORDINATES") != 0) { 
 		printf("\nError in objectfile: it must start with WMCUBE_COORDINATES\n\n");
@@ -1216,14 +1221,22 @@ int loadobj(char *filename) {
 		exit(0);
 	}
 
-	fscanf(fp,"%s",tmp);
+	if (fscanf(fp,"%s",tmp) != 1) {
+		printf("\nError in objectfile: %s\n\n", strerror(errno));
+		fclose(fp);
+		exit(0);
+	}
 	counter = atoi(tmp);
 
 	while ((strcmp(tmp,"WMCUBE_LINES") != 0) && (strcmp(tmp,"WMCUBE_PLANES") != 0)) {		
 
 	 	matrix = (float **)realloc(matrix,(i+1)*sizeof(float *)); mem_alloc_error(matrix);
 		matrix[i] = (float *)malloc(3*sizeof(float)); mem_alloc_error(matrix[i]);
-		fscanf(fp,"%f %f %f",&matrix[i][0],&matrix[i][1],&matrix[i][2]);
+		if (fscanf(fp,"%f %f %f",&matrix[i][0],&matrix[i][1],&matrix[i][2]) != 3) {
+			printf("\nError in objectfile: %s\n\n", strerror(errno));
+			fclose(fp);
+			exit(0);
+		}
 		//printf("\n%d: %f %f %f",atoi(tmp), matrix[i][0],matrix[i][1],matrix[i][2]);
 
 		if (atoi(tmp) != (++i)) { 
@@ -1233,7 +1246,11 @@ int loadobj(char *filename) {
 			fclose(fp);
 			exit(0);
 		}
-		fscanf(fp,"%s",tmp);
+		if (fscanf(fp,"%s",tmp) != 1) {
+			printf("\nError in objectfile: %s\n\n", strerror(errno));
+			fclose(fp);
+			exit(0);
+		}
 
 		if (feof(fp)) {
 			printf("\nError in objectfile: you must have a section WMCUBE_LINES or WMCUBE_PLANES\n\n");
@@ -1251,7 +1268,12 @@ int loadobj(char *filename) {
 		while (1) {
 		
 			cline = (int *)realloc(cline,(i+2)*sizeof(int)); mem_alloc_error(cline);
-			fscanf(fp,"%d %d",&cline[i++],&cline[i++]);
+			if (fscanf(fp,"%d %d",&cline[i],&cline[i+1]) != 2) {
+				printf("\nError in objectfile: %s\n\n", strerror(errno));
+				fclose(fp);
+				exit(0);
+			}
+			i+=2;
 			//printf("\n%d %d",cline[i-2],cline[i-1]);
 			if (feof(fp)) break;
 		
@@ -1270,7 +1292,11 @@ int loadobj(char *filename) {
 		while (1) {	
 			planes = (int **)realloc(planes,(i+1)*sizeof(int *)); mem_alloc_error(planes);
 			planes[i] = (int *)malloc(3*sizeof(int)); mem_alloc_error(planes[i]);
-			fscanf(fp,"%d %d %d",&planes[i][0],&planes[i][1],&planes[i][2]);
+			if (fscanf(fp,"%d %d %d",&planes[i][0],&planes[i][1],&planes[i][2]) != 3) {
+				printf("\nError in objectfile: %s\n\n", strerror(errno));
+				fclose(fp);
+				exit(0);
+			}
 			//printf("\n%d: %d %d %d",i,planes[i][0],planes[i][1],planes[i][2]);
 
 			planes[i][0]--; planes[i][1]--; planes[i][2]--;
 
design & coding: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
current maintainer: Michael Shigorin