Replace BUFSIZ with HCBUFSIZ and move them from stack to heap

This commit is contained in:
Jens Steube
2016-03-26 10:37:59 +01:00
parent 3f694cf960
commit 0fdebf904d
7 changed files with 123 additions and 85 deletions
+2 -2
View File
@@ -486,7 +486,7 @@ int mangle_title (char arr[BLOCK_SIZE], int arr_len)
return (arr_len);
}
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max)
int generate_random_rule (char *rule_buf, u32 rp_gen_func_min, u32 rp_gen_func_max)
{
u32 rp_gen_num = get_random_num (rp_gen_func_min, rp_gen_func_max);
@@ -929,7 +929,7 @@ int apply_rule_cpu (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, c
return (out_len);
}
int cpu_rule_to_kernel_rule (char rule_buf[BUFSIZ], uint rule_len, kernel_rule_t *rule)
int cpu_rule_to_kernel_rule (char *rule_buf, uint rule_len, kernel_rule_t *rule)
{
uint rule_pos;
uint rule_cnt;
+1 -1
View File
@@ -53,7 +53,7 @@ int mangle_chr_decr (u8 arr[BLOCK_SIZE], int arr_len, int upos);
int mangle_title (char arr[BLOCK_SIZE], int arr_len);
int generate_random_rule (char rule_buf[RP_RULE_BUFSIZ], u32 rp_gen_func_min, u32 rp_gen_func_max);
int apply_rule_cpu (char *rule, int rule_len, char in[BLOCK_SIZE], int in_len, char out[BLOCK_SIZE]);
int cpu_rule_to_kernel_rule (char rule_buf[BUFSIZ], uint rule_len, kernel_rule_t *rule);
int cpu_rule_to_kernel_rule (char *rule_buf, uint rule_len, kernel_rule_t *rule);
bool class_num (char c);
bool class_lower (char c);
+10 -6
View File
@@ -11,7 +11,7 @@
#define RP_GEN_FUNC_MAX 4
#define PW_MAX 32
#define LINE_SIG_LEN RP_GEN_FUNC_MAX * 2 + 1
3
int max_len = 0;
#include "cpu_rules.h"
@@ -59,7 +59,9 @@ int main (int argc, char **argv)
{
FILE *fp = stdin;
char rule_buf[BUFSIZ];
char *rule_buf = (char *) malloc (HCBUFSIZ);
char *line_buf = (char *) mymalloc (HCBUFSIZ);
int rp_gen_func_min = RP_GEN_FUNC_MIN;
int rp_gen_func_max = RP_GEN_FUNC_MAX;
@@ -72,9 +74,7 @@ int main (int argc, char **argv)
if (feof (fp)) break;
char line_buf[BUFSIZ + 1];
char *line_ptr = fgets (line_buf, BUFSIZ, fp);
char *line_ptr = fgets (line_buf, HCBUFSIZ - 1, fp);
if (line_ptr == NULL) continue;
@@ -116,7 +116,7 @@ int main (int argc, char **argv)
}
else
{
strncpy (rule_buf, argv[1], BUFSIZ);
strncpy (rule_buf, argv[1], HCBUFSIZ - 1);
rule_len = strlen (rule_buf);
}
@@ -204,5 +204,9 @@ int main (int argc, char **argv)
fclose (fp);
free (line_buf);
free (rule_buf);
return 0;
}