aboutsummaryrefslogtreecommitdiff
blob: d67d29f2dbb1cd25679aed74976deda48041c4a4 (plain)
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
--- extensions/ebt_among.c.dist	2015-03-11 22:04:19.512855582 +0000
+++ extensions/ebt_among.c	2015-03-11 22:07:15.814269639 +0000
@@ -197,7 +197,7 @@ static struct ebt_mac_wormhash *create_w
 
 		/* collect MAC; all its bytes are followed by ':' (colon),
 		 * except for the last one which can be followed by 
-		 * ',' (comma), '=' or '\0' */
+		 * ',' (comma), '=', newline or '\0' */
 		for (i = 0; i < 5; i++) {
 			if (read_until(&pc, ":", token, 2) < 0
 			    || token[0] == 0) {
@@ -213,7 +213,7 @@ static struct ebt_mac_wormhash *create_w
 			}
 			pc++;
 		}
-		if (read_until(&pc, "=,", token, 2) == -2 || token[0] == 0) {
+		if (read_until(&pc, "=,\n", token, 2) == -2 || token[0] == 0) {
 			ebt_print_error("MAC parse error: %.20s", anchor);
 			return NULL;
 		}
@@ -238,7 +238,7 @@ static struct ebt_mac_wormhash *create_w
 				}
 				pc++;
 			}
-			if (read_until(&pc, ",", token, 3) == -2 || token[0] == 0) {
+			if (read_until(&pc, ",\n", token, 3) == -2 || token[0] == 0) {
 				ebt_print_error("IP parse error: %.20s", anchor);
 				return NULL;
 			}
@@ -279,14 +279,14 @@ static struct ebt_mac_wormhash *create_w
 		/* now `pc' points to comma if we are here; */
 		/* increment this to the next char */
 		/* but first assert :-> */
-		if (*pc != ',') {
-			ebt_print_error("Something went wrong; no comma...\n");
+		if (*pc != ',' && *pc != '\n') {
+			ebt_print_error("Something went wrong; no comma or newline...\n");
 			return NULL;
 		}
 		pc++;
 
 		/* again check if end of string was reached; */
-		/* we allow an ending comma */
+		/* we allow an ending comma or newline */
 		if (!*pc) {
 			break;
 		}
@@ -345,8 +345,6 @@ static int parse(int c, char **argv, int
 				ebt_print_error("Couldn't map file to memory");
 			if (optarg[flen-1] != '\n')
 				ebt_print_error("File should end with a newline");
-			if (strchr(optarg, '\n') != optarg+flen-1)
-				ebt_print_error("File should only contain one line");
 			optarg[flen-1] = '\0';
 			if (ebt_errormsg[0] != '\0') {
 				munmap(argv, flen);
@@ -424,7 +422,9 @@ static void wormhash_printout(const stru
 			ip = (unsigned char *) &p->ip;
 			printf("=%u.%u.%u.%u", ip[0], ip[1], ip[2], ip[3]);
 		}
-		printf(",");
+		if (i < (wh->poolsize - 1)) {
+			printf(",");
+		}
 	}
 	printf(" ");
 }