diff --git a/cmd.c b/cmd.c index bdd4f65..bb77cc0 100644 --- a/cmd.c +++ b/cmd.c @@ -14,8 +14,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include #include +#include #include #include #include diff --git a/icb.c b/icb.c index 513b08b..093a06f 100644 --- a/icb.c +++ b/icb.c @@ -14,8 +14,9 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include #include +#include #include #include #include @@ -30,7 +31,7 @@ #include "icbd.h" extern int creategroups; -extern char srvname[MAXHOSTNAMELEN]; +extern char srvname[NI_MAXHOST]; void icb_command(struct icb_session *, char *, char *); void icb_groupmsg(struct icb_session *, char *); @@ -49,7 +50,7 @@ icb_init(void) if (strlen(srvname) == 0) (void)gethostname(srvname, sizeof srvname); /* - * MAXHOSTNAMELEN is usually greater than what we + * NI_MAXHOST is usually greater than what we * can actually send, hence truncation: */ if (strlen(srvname) > 200) @@ -184,6 +185,8 @@ icb_login(struct icb_session *is, char *grp, char *nick, char *client) if (client && strlen(client) > 0) icb_vis(is->client, client, sizeof is->client, VIS_SP); + else + strlcpy(is->client, is->nick, sizeof is->client); is->group = ig; is->login = time(NULL); is->last = getmonotime(); diff --git a/icb.h b/icb.h index aecfb73..96c5c4a 100644 --- a/icb.h +++ b/icb.h @@ -76,7 +76,7 @@ struct icb_session { char nick[ICB_MAXNICKLEN]; char client[ICB_MAXNICKLEN]; char host[ICB_MAXHOSTLEN]; - char hostname[MAXHOSTNAMELEN]; + char hostname[NI_MAXHOST]; char buffer[ICB_MSGSIZE]; struct sockaddr_storage ss; struct event ev; diff --git a/icbd.h b/icbd.h index 5e6eaaf..124b5c5 100644 --- a/icbd.h +++ b/icbd.h @@ -19,6 +19,10 @@ #define TCP_BACKLOG 5 +#ifndef MIN +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#endif + #define EVBUFFER_FD(x) (EVENT_FD(&(x)->ev_read)) extern int verbose; diff --git a/logger.c b/logger.c index e305133..46bf8e6 100644 --- a/logger.c +++ b/logger.c @@ -15,13 +15,13 @@ * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ -#include +#include #include #include #include -#include #include #include +#include #include #include #include