Browse code

add min/max fl in loadhash

TODO:
- port to non-mpool
- sigtool and stuff
- enforce md5 only in md[bu]
- tune mpool?

aCaB authored on 2011/01/15 06:59:43
Showing 1 changed files
... ...
@@ -1860,7 +1860,7 @@ static int cli_loadign(FILE *fs, struct cl_engine *engine, unsigned int options,
1860 1860
 #define MD5_MDB	    1
1861 1861
 #define MD5_FP	    2
1862 1862
 
1863
-#define MD5_TOKENS 3
1863
+#define MD5_TOKENS 5
1864 1864
 static int cli_loadhash(FILE *fs, struct cl_engine *engine, unsigned int *signo, unsigned int mode, unsigned int options, struct cli_dbio *dbio, const char *dbname)
1865 1865
 {
1866 1866
 	const char *tokens[MD5_TOKENS + 1];
... ...
@@ -1888,10 +1888,26 @@ static int cli_loadhash(FILE *fs, struct cl_engine *engine, unsigned int *signo,
1888 1888
 	    strcpy(buffer_cpy, buffer);
1889 1889
 
1890 1890
 	tokens_count = cli_strtokenize(buffer, ':', MD5_TOKENS + 1, tokens);
1891
-	if(tokens_count != MD5_TOKENS) {
1891
+	if(tokens_count < 3) {
1892 1892
 	    ret = CL_EMALFDB;
1893 1893
 	    break;
1894 1894
 	}
1895
+	if(tokens_count > MD5_TOKENS - 2) {
1896
+	    unsigned int req_fl = atoi(tokens[MD5_TOKENS - 2]);
1897
+
1898
+	    if(tokens_count > MD5_TOKENS) {
1899
+		ret = CL_EMALFDB;
1900
+		break;
1901
+	    }
1902
+
1903
+	    if(cl_retflevel() < req_fl)
1904
+		continue;
1905
+	    if(tokens_count == MD5_TOKENS) {
1906
+		req_fl = atoi(tokens[MD5_TOKENS - 1]);
1907
+		if(cl_retflevel() > req_fl)
1908
+		    continue;
1909
+	    }
1910
+	}
1895 1911
 
1896 1912
 	size = strtol(tokens[size_field], (char **)&pt, 10);
1897 1913
 	if(*pt || !size || size >= 0xffffffff) {