Module: ngircd.git Branch: master Commit: 62865f7e1910d08ad8d72cb89f830f6d9411ffa2 URL: http://ngircd.barton.de/cgi-bin/gitweb.cgi?p=ngircd.git&a=commit;h=62865...
Author: Federico G. Schwindt fgsch@lodoss.net Date: Thu Oct 17 22:10:53 2013 +0100
Add support for longer config lines
With the introduction of CipherList we could have longer config lines. Handle up to 1024 bytes and warn if the line will be truncated.
---
src/ngircd/client.c | 2 +- src/ngircd/conf.c | 10 ++++++++-- src/ngircd/defines.h | 2 +- src/ngircd/hash.c | 2 +- src/ngircd/irc-login.c | 2 +- src/ngircd/irc-server.c | 2 +- src/ngircd/numeric.c | 4 ++-- src/ngircd/parse.c | 2 +- 8 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/src/ngircd/client.c b/src/ngircd/client.c index b1a371f..5f01648 100644 --- a/src/ngircd/client.c +++ b/src/ngircd/client.c @@ -238,7 +238,7 @@ Client_Destroy( CLIENT *Client, const char *LogMsg, const char *FwdMsg, bool Sen /* remove a client */ CLIENT *last, *c; - char msg[LINE_LEN]; + char msg[COMMAND_LEN]; const char *txt;
assert( Client != NULL ); diff --git a/src/ngircd/conf.c b/src/ngircd/conf.c index 372b14c..1627587 100644 --- a/src/ngircd/conf.c +++ b/src/ngircd/conf.c @@ -1063,7 +1063,7 @@ static void Read_Config_File(const char *File, FILE *fd) /* Read configuration file */ section[0] = '\0'; while (true) { - if (!fgets(str, LINE_LEN, fd)) + if (!fgets(str, sizeof(str), fd)) break; ngt_TrimStr(str); line++; @@ -1072,6 +1072,12 @@ static void Read_Config_File(const char *File, FILE *fd) if (str[0] == ';' || str[0] == '#' || str[0] == '\0') continue;
+ if (strlen(str) >= sizeof(str) - 1) { + Config_Error(LOG_WARNING, "%s, line %d too long!", + File, line); + continue; + } + /* Is this the beginning of a new section? */ if ((str[0] == '[') && (str[strlen(str) - 1] == ']')) { strlcpy(section, str, sizeof(section)); @@ -1474,7 +1480,7 @@ Handle_GLOBAL(const char *File, int Line, char *Var, char *Arg ) len = strlen(Arg); if (len == 0) return; - if (len >= LINE_LEN) { + if (len >= 127) { Config_Error_TooLong(File, Line, Var); return; } diff --git a/src/ngircd/defines.h b/src/ngircd/defines.h index efe3186..361564f 100644 --- a/src/ngircd/defines.h +++ b/src/ngircd/defines.h @@ -36,7 +36,7 @@ /* Generic buffer sizes */
/** Max. length of a line in the configuration file. */ -#define LINE_LEN 256 +#define LINE_LEN 1024
/** Max. length of a log message. */ #define MAX_LOG_MSG_LEN 256 diff --git a/src/ngircd/hash.c b/src/ngircd/hash.c index c75b57d..3c60038 100644 --- a/src/ngircd/hash.c +++ b/src/ngircd/hash.c @@ -37,7 +37,7 @@ static UINT32 jenkins_hash PARAMS((UINT8 *k, UINT32 length, UINT32 initval)); GLOBAL UINT32 Hash( const char *String ) { - char buffer[LINE_LEN]; + char buffer[COMMAND_LEN];
strlcpy(buffer, String, sizeof(buffer)); return jenkins_hash((UINT8 *)ngt_LowerStr(buffer), diff --git a/src/ngircd/irc-login.c b/src/ngircd/irc-login.c index d1b4033..4695272 100644 --- a/src/ngircd/irc-login.c +++ b/src/ngircd/irc-login.c @@ -630,7 +630,7 @@ GLOBAL bool IRC_QUIT( CLIENT *Client, REQUEST *Req ) { CLIENT *target; - char quitmsg[LINE_LEN]; + char quitmsg[COMMAND_LEN];
assert(Client != NULL); assert(Req != NULL); diff --git a/src/ngircd/irc-server.c b/src/ngircd/irc-server.c index 030c3cd..b0abb7c 100644 --- a/src/ngircd/irc-server.c +++ b/src/ngircd/irc-server.c @@ -53,7 +53,7 @@ GLOBAL bool IRC_SERVER( CLIENT *Client, REQUEST *Req ) { - char str[LINE_LEN]; + char str[100]; CLIENT *from, *c; int i;
diff --git a/src/ngircd/numeric.c b/src/ngircd/numeric.c index a43739f..ad7e042 100644 --- a/src/ngircd/numeric.c +++ b/src/ngircd/numeric.c @@ -47,7 +47,7 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan) { CL2CHAN *cl2chan; CLIENT *cl; - char str[LINE_LEN], *ptr; + char str[COMMAND_LEN], *ptr; bool njoin, xop;
/* Check features of remote server */ @@ -82,7 +82,7 @@ Announce_Channel(CLIENT *Client, CHANNEL *Chan) strlcat(str, Client_ID(cl), sizeof(str));
/* Send the data if the buffer is "full" */ - if (strlen(str) > (LINE_LEN - CLIENT_NICK_LEN - 8)) { + if (strlen(str) > (sizeof(str) - CLIENT_NICK_LEN - 8)) { if (!IRC_WriteStrClient(Client, "%s", str)) return DISCONNECTED; snprintf(str, sizeof(str), "NJOIN %s :", diff --git a/src/ngircd/parse.c b/src/ngircd/parse.c index 5006d2f..2c7ba94 100644 --- a/src/ngircd/parse.c +++ b/src/ngircd/parse.c @@ -423,7 +423,7 @@ Handle_Numeric(CLIENT *client, REQUEST *Req) { 376, IRC_Num_ENDOFMOTD } }; int i, num; - char str[LINE_LEN]; + char str[COMMAND_LEN]; CLIENT *prefix, *target = NULL;
/* Determine target */
ngircd-commits@lists.barton.de