[Kimchi-devel] [PATCH] Fix: Use "max_request_body_size" value as int instead of string

Aline Manera alinefm at linux.vnet.ibm.com
Wed Sep 10 02:03:50 UTC 2014


Reviewed-by: Aline Manera <alinefm at linux.vnet.ibm.com>

On 09/09/2014 10:49 PM, Crístian Viana wrote:
> The CherryPy variable "max_request_body_size" should be a number value,
> in bytes. The current code runs something like
> "eval('max_body_size' * 1024)", where 'max_body_size' is the value read
> from the external configuration file, in kilobytes. Multiplying a string
> by a number in Python creates a new string repeating the original string
> a number of times. We expect a multiplication, not a string repetition.
> This bug was introduced by commit e3b79e3.
>
> Multiply the number 1024 by another number (i.e. the "eval" result), not
> a string.
>
> Signed-off-by: Crístian Viana <vianac at linux.vnet.ibm.com>
> ---
>   src/kimchi/server.py | 4 +++-
>   src/kimchid.in       | 2 +-
>   2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/src/kimchi/server.py b/src/kimchi/server.py
> index 1c3b360..775313c 100644
> --- a/src/kimchi/server.py
> +++ b/src/kimchi/server.py
> @@ -87,7 +87,9 @@ class Server(object):
>           # directly. You must go through the proxy.
>           cherrypy.server.socket_host = '127.0.0.1'
>           cherrypy.server.socket_port = options.cherrypy_port
> -        cherrypy.server.max_request_body_size = eval(options.max_body_size)
> +
> +        max_body_size_in_bytes = eval(options.max_body_size) * 1024
> +        cherrypy.server.max_request_body_size = max_body_size_in_bytes
>   
>           cherrypy.log.screen = True
>           cherrypy.log.access_file = options.access_log
> diff --git a/src/kimchid.in b/src/kimchid.in
> index 075b744..0746ba6 100644
> --- a/src/kimchid.in
> +++ b/src/kimchid.in
> @@ -87,7 +87,7 @@ def main(options):
>       setattr(options, 'ssl_cert', config.config.get('server', 'ssl_cert'))
>       setattr(options, 'ssl_key', config.config.get('server', 'ssl_key'))
>       setattr(options, 'max_body_size',
> -            config.config.get('server', 'max_body_size')*1024)
> +            config.config.get('server', 'max_body_size'))
>   
>       kimchi.server.main(options)
>   




More information about the Kimchi-devel mailing list