commit f698f16967ae8341ff4b506f96b8cd5790c05d27
Author: Oswald Buddenhagen <[email protected]>
Date: Sun Jul 1 13:22:17 2018 +0200
fix type of 'port' and check its range in config reader
src/drv_imap.c | 12 +++++++++---
src/socket.h | 2 +-
2 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/drv_imap.c b/src/drv_imap.c
index 4fbc43e..d76328e 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -3132,9 +3132,15 @@ imap_parse_store( conffile_t *cfg, store_conf_t **storep
)
server->pass = nfstrdup( cfg->val );
else if (!strcasecmp( "PassCmd", cfg->cmd ))
server->pass_cmd = nfstrdup( cfg->val );
- else if (!strcasecmp( "Port", cfg->cmd ))
- server->sconf.port = parse_int( cfg );
- else if (!strcasecmp( "Timeout", cfg->cmd ))
+ else if (!strcasecmp( "Port", cfg->cmd )) {
+ int port = parse_int( cfg );
+ 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 );
else if (!strcasecmp( "PipelineDepth", cfg->cmd )) {
if ((server->max_in_progress = parse_int( cfg )) < 1) {
diff --git a/src/socket.h b/src/socket.h
index 36ebe09..f80c2ef 100644
--- a/src/socket.h
+++ b/src/socket.h
@@ -43,7 +43,7 @@ enum {
typedef struct {
char *tunnel;
char *host;
- int port;
+ ushort port;
int timeout;
#ifdef HAVE_LIBSSL
char *cert_file;
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel