diff options
author | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-16 13:47:36 +0000 |
---|---|---|
committer | Vsevolod Stakhov <vsevolod@highsecure.ru> | 2015-12-16 13:47:36 +0000 |
commit | 0e84a106463d59421cc235acafe34ae764e35bff (patch) | |
tree | fd19362f42f2beea5e30d29a92ba08d49aeb7ab5 /src | |
parent | 59b0122f6c8a8f92060f859c1a9bbd75f5fe3bd5 (diff) | |
download | rspamd-0e84a106463d59421cc235acafe34ae764e35bff.tar.gz rspamd-0e84a106463d59421cc235acafe34ae764e35bff.zip |
Rewrite preprocess script to avoid string literal limit in C
Diffstat (limited to 'src')
-rw-r--r-- | src/rspamadm/lua_preprocess.pl | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/rspamadm/lua_preprocess.pl b/src/rspamadm/lua_preprocess.pl index 014db3a98..4a84689a4 100644 --- a/src/rspamadm/lua_preprocess.pl +++ b/src/rspamadm/lua_preprocess.pl @@ -15,9 +15,10 @@ sub quote_file { quote_file($inc, $out); } else { - s/\"/\\"/g; - s/^(.*)$/"$1\\n"/; - print $out $_; + s/(.)/'$1',/g; # split as 'c', + s/\'\\\'/\'\\\\'/g; # escape backslashes + s/\'\'\'/\'\\\'\'/g; # escape single quotes + print $out "$_'\\n',"; } } } @@ -35,12 +36,12 @@ foreach my $file (@files) { #ifndef ${definename}_GUARD_H #define ${definename}_GUARD_H -static const char ${varname}\[\] = "" +static const char ${varname}\[\] = { EOD quote_file($in, $out); print $out <<EOD; -""; +'\\0'}; #endif EOD } |