fix type of 'port' and check its range in config reader

This commit is contained in:
Oswald Buddenhagen 2018-07-01 13:22:17 +02:00
parent 470210fa86
commit f698f16967
2 changed files with 10 additions and 4 deletions

View File

@ -3132,9 +3132,15 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep )
server->pass = nfstrdup( cfg->val ); server->pass = nfstrdup( cfg->val );
else if (!strcasecmp( "PassCmd", cfg->cmd )) else if (!strcasecmp( "PassCmd", cfg->cmd ))
server->pass_cmd = nfstrdup( cfg->val ); server->pass_cmd = nfstrdup( cfg->val );
else if (!strcasecmp( "Port", cfg->cmd )) else if (!strcasecmp( "Port", cfg->cmd )) {
server->sconf.port = parse_int( cfg ); int port = parse_int( cfg );
else if (!strcasecmp( "Timeout", cfg->cmd )) if ((unsigned)port > 0xffff) {
error( "%s:%d: Invalid port number\n", cfg->file, cfg->line );
cfg->err = 1;
} else {
server->sconf.port = (ushort)port;
}
} else if (!strcasecmp( "Timeout", cfg->cmd ))
server->sconf.timeout = parse_int( cfg ); server->sconf.timeout = parse_int( cfg );
else if (!strcasecmp( "PipelineDepth", cfg->cmd )) { else if (!strcasecmp( "PipelineDepth", cfg->cmd )) {
if ((server->max_in_progress = parse_int( cfg )) < 1) { if ((server->max_in_progress = parse_int( cfg )) < 1) {

View File

@ -43,7 +43,7 @@ enum {
typedef struct { typedef struct {
char *tunnel; char *tunnel;
char *host; char *host;
int port; ushort port;
int timeout; int timeout;
#ifdef HAVE_LIBSSL #ifdef HAVE_LIBSSL
char *cert_file; char *cert_file;