[PATCH 07/40] crda: fix regression when using reglib_for_each_country()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: "Luis R. Rodriguez" <mcgrof@xxxxxxxxxxxxxxxx>

When reglib_for_each_country() was introduced via ebcbfcf4
its users were not updated with the possibility of rd being
NULL due to the fact that the parsed file could be invalid
or empty. The users

mcgrof at frijol ~/devel/crda (git::master)$ git describe --contains 7a09f4dd
v1.1.3~8

mcgrof at frijol ~/devel/crda (git::master)$ git describe --contains ebcbfcf45
v1.1.3~9

This regression exists since v1.1. Fix this.

Signed-off-by: Luis R. Rodriguez <mcgrof at do-not-panic.com>
---
 intersect.c |    6 ++++++
 regdbdump.c |    7 +++++++
 2 files changed, 13 insertions(+)

diff --git a/intersect.c b/intersect.c
index 1c00a67..8f826a0 100644
--- a/intersect.c
+++ b/intersect.c
@@ -73,6 +73,12 @@ int main(int argc, char **argv)
 		intersected++;
 	}
 
+	if (!idx) {
+		printf("Invalid or empty regulatory file, note: "
+		       "a binary regulatory file should be used.\n");
+		return -EINVAL;
+	}
+
 	if (idx == 1) {
 		world = (struct ieee80211_regdomain *) rd;
 		rd = NULL;
diff --git a/regdbdump.c b/regdbdump.c
index 26cbef7..dcbed71 100644
--- a/regdbdump.c
+++ b/regdbdump.c
@@ -1,4 +1,5 @@
 #include <stdio.h>
+#include <errno.h>
 #include "reglib.h"
 
 int main(int argc, char **argv)
@@ -16,5 +17,11 @@ int main(int argc, char **argv)
 		free((struct ieee80211_regdomain *) rd);
 	}
 
+	if (!idx) {
+		printf("Invalid or empty regulatory file, note: "
+		       "a binary regulatory file should be used.\n");
+		return -EINVAL;
+	}
+
 	return 0;
 }
-- 
1.7.10.4




[Index of Archives]     [LM Sensors]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux