On 23 Apr 2008, at 01:59, Perki Pat wrote:
> Hi!, last monday there was a meeting by Alo at the university of
> Salamanca, and a few of the attendees decided to take a look on
> cherokee.
Hello Perki! I'm delighted you have finally come along.. :-)
> The cherokee-admin doesn't check the range port when you use the
> option
> -p. For example if you use cherokee-admin -p 100000, the program open
> aleatory port. The solution is checking the range of ports ( 0 -
> 65000~)
> when you use the option -p.
>
> --- main_admin.c 2008-04-23 01:46:52.000000000 +0200
> +++ main_admin.c.new 2008-04-23 01:43:42.000000000 +0200
> @@ -143,6 +143,11 @@
> break;
> case 'p':
> port = atoi(optarg);
> + if(port>65535 || port <=0) {
> + fprintf(stderr,
> + "Bad port number, port range is between
> 1 and 65535\n");
> + exit(1);
> + }
> break;
> case 'd':
> document_root = strdup(optarg);
The patch is good, congrats! However, there is a couple of changes
that would improve the patch before we apply it:
- I would move the checking code to the initialize_server_socket()
function in cherokee/server.c file. In that way the port would always
be checked, not only when the -p parameter is used; for instance, it
would ensure that a port read from a configuration file is correct as
well.
- There are a few macros from printing errors:
PRINT_ERROR_S: Print en error with no parameters.
PRINT_ERROR: Print an error with parameters (needs to be formated).
PRINT_MSG_S: Print a message with no parameters.
PRINT_MSG: Print a message with parameters (needs to be formated).
In this case, I would use PRINT_ERROR_S.
- Ah, and finally, instead of calling exit() it would be better if you
used: return ret_error; That is our equivalent of raising and
exception (well, sort of).
> I don't remember to have read about coding style at Cherokee's web. I
> haven't colaborated in any software projects, every help is welcomed.
There isn't any document defining the coding style, although it would
very interesting to have one. For now the best practice is to look at
the code to see how things are written.
--
Greetings, alo.
_______________________________________________
Cherokee mailing list
[email protected]
http://cherokee-project.com/cgi-bin/mailman/listinfo/cherokee