cyrusimap / cyrus-imapd

Cyrus IMAP is an email, contacts and calendar server
http://cyrusimap.org
Other
543 stars 149 forks source link

timsieved: share maxscriptsize between actions.c and lex.c #1954

Closed dilyanpalauzov closed 7 years ago

dilyanpalauzov commented 7 years ago
--- a/timsieved/actions.c
+++ b/timsieved/actions.c
@@ -749,7 +749,7 @@ int cmd_havespace(struct protstream *conn, const struct buf *sieve_name, unsigne
 {
     int result;
     int maxscripts;
-    unsigned long maxscriptsize;
+    extern unsigned long maxscriptsize;

     result = scriptname_valid(sieve_name);
     if (result!=TIMSIEVE_OK)
@@ -759,9 +759,6 @@ int cmd_havespace(struct protstream *conn, const struct buf *sieve_name, unsigne
     }

     /* see if the size of the script is too big */
-    maxscriptsize = config_getint(IMAPOPT_SIEVE_MAXSCRIPTSIZE);
-    maxscriptsize *= 1024;
-
     if (num > maxscriptsize)
     {
         prot_printf(conn,
diff --git a/timsieved/lex.c b/timsieved/lex.c
--- a/timsieved/lex.c
+++ b/timsieved/lex.c
@@ -116,7 +116,7 @@ static int token_lookup(const char *str)

 /* current state the lexer is in */
 static int lexer_state = LEXER_STATE_NORMAL;
-static unsigned long maxscriptsize=0;
+HIDDEN unsigned long maxscriptsize = 0;
 static char *buffer;

 #define ERR() {                                                         \
@@ -134,14 +134,11 @@ void lex_setrecovering(void)
   lexer_state = LEXER_STATE_RECOVER;
 }

-int lex_init(void)
+void lex_init(void)
 {
-  maxscriptsize = config_getint(IMAPOPT_SIEVE_MAXSCRIPTSIZE);
-  maxscriptsize *= 1024;
+  maxscriptsize = config_getint(IMAPOPT_SIEVE_MAXSCRIPTSIZE) * 1024;

   buffer = (char *) xmalloc(maxscriptsize);
-
-  return 0;
 }

 /**
diff --git a/timsieved/lex.h b/timsieved/lex.h
--- a/timsieved/lex.h
+++ b/timsieved/lex.h
@@ -83,7 +83,7 @@
 #define RENAMESCRIPT 413

-int lex_init(void);
+void lex_init(void);

 int timlex(struct buf *outstr, unsigned long *outnum,  struct protstream *stream);
ksmurchison commented 7 years ago

Fixed with https://github.com/cyrusimap/cyrus-imapd/commit/0f514b139af62751787605e65476965cb7391089