2 * IRC - Internet Relay Chat, ircd/gline.c
3 * Copyright (C) 1990 Jarkko Oikarinen and
4 * University of Oulu, Finland
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 1, or (at your option)
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
27 #include "ircd_alloc.h"
28 #include "ircd_features.h"
30 #include "ircd_reply.h"
31 #include "ircd_snprintf.h"
32 #include "ircd_string.h"
45 #include "sys.h" /* FALSE bleah */
52 #include <arpa/inet.h> /* for inet_ntoa */
54 #define CHECK_APPROVED 0 /* Mask is acceptable */
55 #define CHECK_OVERRIDABLE 1 /* Mask is acceptable, but not by default */
56 #define CHECK_REJECTED 2 /* Mask is totally unacceptable */
58 #define MASK_WILD_0 0x01 /* Wildcards in the last position */
59 #define MASK_WILD_1 0x02 /* Wildcards in the next-to-last position */
61 #define MASK_WILD_MASK 0x03 /* Mask out the positional wildcards */
63 #define MASK_WILDS 0x10 /* Mask contains wildcards */
64 #define MASK_IP 0x20 /* Mask is an IP address */
65 #define MASK_HALT 0x40 /* Finished processing mask */
67 struct Gline* GlobalGlineList = 0;
68 struct Gline* BadChanGlineList = 0;
71 canon_userhost(char *userhost, char **user_p, char **host_p, char *def_user)
75 if (!(tmp = strchr(userhost, '@'))) {
86 make_gline(char *user, char *host, char *reason, time_t expire, time_t lastmod,
89 struct Gline *gline, *sgline, *after = 0;
91 if (!(flags & GLINE_BADCHAN)) { /* search for overlapping glines first */
93 for (gline = GlobalGlineList; gline; gline = sgline) {
94 sgline = gline->gl_next;
96 if (gline->gl_expire <= CurrentTime)
98 else if ((gline->gl_flags & GLINE_LOCAL) != (flags & GLINE_LOCAL))
100 else if (!mmatch(gline->gl_user, user) && /* gline contains new mask */
101 !mmatch(gline->gl_host, host)) {
102 if (expire <= gline->gl_expire) /* will expire before wider gline */
105 after = gline; /* stick new gline after this one */
106 } else if (!mmatch(user, gline->gl_user) && /* new mask contains gline */
107 !mmatch(host, gline->gl_host) &&
108 gline->gl_expire <= expire) /* gline expires before new one */
109 gline_free(gline); /* save some memory */
113 gline = (struct Gline *)MyMalloc(sizeof(struct Gline)); /* alloc memory */
116 DupString(gline->gl_reason, reason); /* initialize gline... */
117 gline->gl_expire = expire;
118 gline->gl_lastmod = lastmod;
119 gline->gl_flags = flags & GLINE_MASK;
121 if (flags & GLINE_BADCHAN) { /* set a BADCHAN gline */
122 DupString(gline->gl_user, user); /* first, remember channel */
125 gline->gl_next = BadChanGlineList; /* then link it into list */
126 gline->gl_prev_p = &BadChanGlineList;
127 if (BadChanGlineList)
128 BadChanGlineList->gl_prev_p = &gline->gl_next;
129 BadChanGlineList = gline;
131 DupString(gline->gl_user, user); /* remember them... */
132 DupString(gline->gl_host, host);
134 if (check_if_ipmask(host)) { /* mark if it's an IP mask */
140 c_class = sscanf(host,"%d.%d.%d.%d/%d",
141 &ad[0],&ad[1],&ad[2],&ad[3], &bits2);
143 gline->bits=c_class*8;
148 ircd_snprintf(0, ipname, sizeof(ipname), "%d.%d.%d.%d", ad[0], ad[1],
150 gline->ipnum.s_addr = inet_addr(ipname);
151 Debug((DEBUG_DEBUG,"IP gline: %08x/%i",gline->ipnum.s_addr,gline->bits));
152 gline->gl_flags |= GLINE_IPMASK;
156 gline->gl_next = after->gl_next;
157 gline->gl_prev_p = &after->gl_next;
159 after->gl_next->gl_prev_p = &gline->gl_next;
160 after->gl_next = gline;
162 gline->gl_next = GlobalGlineList; /* then link it into list */
163 gline->gl_prev_p = &GlobalGlineList;
165 GlobalGlineList->gl_prev_p = &gline->gl_next;
166 GlobalGlineList = gline;
174 do_gline(struct Client *cptr, struct Client *sptr, struct Gline *gline)
176 struct Client *acptr;
177 int fd, retval = 0, tval;
179 if (!GlineIsActive(gline)) /* no action taken on inactive glines */
182 for (fd = HighestFd; fd >= 0; --fd) {
186 if ((acptr = LocalClientArray[fd])) {
187 if (!cli_user(acptr))
190 if (cli_user(acptr)->username &&
191 match (gline->gl_user, (cli_user(acptr))->username) != 0)
194 if (GlineIsIpMask(gline)) {
195 Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
196 if (((cli_ip(acptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
200 if (match(gline->gl_host, cli_sockhost(acptr)) != 0)
204 /* ok, here's one that got G-lined */
205 send_reply(acptr, SND_EXPLICIT | ERR_YOUREBANNEDCREEP, ":%s",
208 /* let the ops know about it */
209 sendto_opmask_butone(0, SNO_GLINE, "G-line active for %s",
210 get_client_name(acptr, TRUE));
212 /* and get rid of him */
213 if ((tval = exit_client_msg(cptr, acptr, &me, "G-lined (%s)",
215 retval = tval; /* retain killed status */
222 * This routine implements the mask checking applied to local
223 * G-lines. Basically, host masks must have a minimum of two non-wild
224 * domain fields, and IP masks must have a minimum of 16 bits. If the
225 * mask has even one wild-card, OVERRIDABLE is returned, assuming the
226 * other check doesn't fail.
229 gline_checkmask(char *mask)
231 unsigned int flags = MASK_IP;
232 unsigned int dots = 0;
233 unsigned int ipmask = 0;
235 for (; *mask; mask++) { /* go through given mask */
236 if (*mask == '.') { /* it's a separator; advance positional wilds */
237 flags = (flags & ~MASK_WILD_MASK) | ((flags << 1) & MASK_WILD_MASK);
240 if ((flags & (MASK_IP | MASK_WILDS)) == MASK_IP)
241 ipmask += 8; /* It's an IP with no wilds, count bits */
242 } else if (*mask == '*' || *mask == '?')
243 flags |= MASK_WILD_0 | MASK_WILDS; /* found a wildcard */
244 else if (*mask == '/') { /* n.n.n.n/n notation; parse bit specifier */
246 ipmask = strtoul(mask, &mask, 10);
248 if (*mask || dots != 3 || ipmask > 32 || /* sanity-check to date */
249 (flags & (MASK_WILDS | MASK_IP)) != MASK_IP)
250 return CHECK_REJECTED; /* how strange... */
252 if (ipmask < 32) /* it's a masked address; mark wilds */
255 flags |= MASK_HALT; /* Halt the ipmask calculation */
257 break; /* get out of the loop */
258 } else if (!IsDigit(*mask)) {
259 flags &= ~MASK_IP; /* not an IP anymore! */
264 /* Sanity-check quads */
265 if (dots > 3 || (!(flags & MASK_WILDS) && dots < 3)) {
270 /* update bit count if necessary */
271 if ((flags & (MASK_IP | MASK_WILDS | MASK_HALT)) == MASK_IP)
274 /* Check to see that it's not too wide of a mask */
275 if (flags & MASK_WILDS &&
276 ((!(flags & MASK_IP) && (dots < 2 || flags & MASK_WILD_MASK)) ||
277 (flags & MASK_IP && ipmask < 16)))
278 return CHECK_REJECTED; /* to wide, reject */
280 /* Ok, it's approved; require override if it has wildcards, though */
281 return flags & MASK_WILDS ? CHECK_OVERRIDABLE : CHECK_APPROVED;
285 gline_propagate(struct Client *cptr, struct Client *sptr, struct Gline *gline)
287 if (GlineIsLocal(gline) || (IsUser(sptr) && !gline->gl_lastmod))
290 if (gline->gl_lastmod)
291 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
292 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
293 GlineIsBadChan(gline) ? "" : "@",
294 GlineIsBadChan(gline) ? "" : gline->gl_host,
295 gline->gl_expire - CurrentTime, gline->gl_lastmod,
298 sendcmdto_serv_butone(sptr, CMD_GLINE, cptr,
299 (GlineIsRemActive(gline) ?
300 "* +%s%s%s %Tu :%s" : "* -%s%s%s"),
301 gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
302 GlineIsBadChan(gline) ? "" : gline->gl_host,
303 gline->gl_expire - CurrentTime, gline->gl_reason);
309 gline_add(struct Client *cptr, struct Client *sptr, char *userhost,
310 char *reason, time_t expire, time_t lastmod, unsigned int flags)
312 struct Gline *agline;
313 char uhmask[USERLEN + HOSTLEN + 2];
317 assert(0 != userhost);
320 /* NO_OLD_GLINE allows *@#channel to work correctly */
321 if (*userhost == '#' || *userhost == '&'
322 # ifndef NO_OLD_GLINE
323 || userhost[2] == '#' || userhost[2] == '&'
324 # endif /* OLD_GLINE */
326 if ((flags & GLINE_LOCAL) && !HasPriv(sptr, PRIV_LOCAL_BADCHAN))
327 return send_reply(sptr, ERR_NOPRIVILEGES);
329 flags |= GLINE_BADCHAN;
330 # ifndef NO_OLD_GLINE
331 if (userhost[2] == '#' || userhost[2] == '&')
334 # endif /* OLD_GLINE */
338 canon_userhost(userhost, &user, &host, "*");
340 ircd_snprintf(0, uhmask, sizeof(uhmask), "%s@%s", user, host))
341 return send_reply(sptr, ERR_LONGMASK);
342 else if (MyUser(sptr) || (IsUser(sptr) && flags & GLINE_LOCAL)) {
343 switch (gline_checkmask(host)) {
344 case CHECK_OVERRIDABLE: /* oper overrided restriction */
345 if (flags & GLINE_OPERFORCE)
349 return send_reply(sptr, ERR_MASKTOOWIDE, uhmask);
353 if ((tmp = count_users(uhmask)) >=
354 feature_int(FEAT_GLINEMAXUSERCOUNT) && !(flags & GLINE_OPERFORCE))
355 return send_reply(sptr, ERR_TOOMANYUSERS, tmp);
360 * You cannot set a negative (or zero) expire time, nor can you set an
361 * expiration time for greater than GLINE_MAX_EXPIRE.
363 if (!(flags & GLINE_FORCE) && (expire <= 0 || expire > GLINE_MAX_EXPIRE)) {
364 if (!IsServer(sptr) && MyConnect(sptr))
365 send_reply(sptr, ERR_BADEXPIRE, expire);
369 expire += CurrentTime; /* convert from lifetime to timestamp */
372 sendto_opmask_butone(0, ircd_strncmp(reason, "AUTO", 4) ? SNO_GLINE :
373 SNO_AUTO, "%s adding %s %s for %s%s%s, expiring at "
375 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
377 cli_name((cli_user(sptr))->server),
378 (flags & GLINE_LOCAL) ? "local" : "global",
379 (flags & GLINE_BADCHAN) ? "BADCHAN" : "GLINE", user,
380 (flags & GLINE_BADCHAN) ? "" : "@",
381 (flags & GLINE_BADCHAN) ? "" : host,
382 expire + TSoffset, reason);
385 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
386 "%#C adding %s %s for %s, expiring at %Tu: %s", sptr,
387 flags & GLINE_LOCAL ? "local" : "global",
388 flags & GLINE_BADCHAN ? "BADCHAN" : "GLINE", userhost,
389 expire + TSoffset, reason);
392 agline = make_gline(user, host, reason, expire, lastmod, flags);
394 if (!agline) /* if it overlapped, silently return */
397 gline_propagate(cptr, sptr, agline);
399 if (GlineIsBadChan(agline))
402 return do_gline(cptr, sptr, agline); /* knock off users if necessary */
406 gline_activate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
407 time_t lastmod, unsigned int flags)
409 unsigned int saveflags = 0;
413 saveflags = gline->gl_flags;
415 if (flags & GLINE_LOCAL)
416 gline->gl_flags &= ~GLINE_LDEACT;
418 gline->gl_flags |= GLINE_ACTIVE;
420 if (gline->gl_lastmod) {
421 if (gline->gl_lastmod >= lastmod) /* force lastmod to increase */
424 gline->gl_lastmod = lastmod;
428 if ((saveflags & GLINE_ACTMASK) == GLINE_ACTIVE)
429 return 0; /* was active to begin with */
431 /* Inform ops and log it */
432 sendto_opmask_butone(0, SNO_GLINE, "%s activating global %s for %s%s%s, "
433 "expiring at %Tu: %s",
434 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
436 cli_name((cli_user(sptr))->server),
437 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
438 gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
439 GlineIsBadChan(gline) ? "" : gline->gl_host,
440 gline->gl_expire + TSoffset, gline->gl_reason);
442 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
443 "%#C activating global %s for %s%s%s, expiring at %Tu: %s", sptr,
444 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
445 GlineIsBadChan(gline) ? "" : "@",
446 GlineIsBadChan(gline) ? "" : gline->gl_host,
447 gline->gl_expire + TSoffset, gline->gl_reason);
449 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
450 gline_propagate(cptr, sptr, gline);
452 return GlineIsBadChan(gline) ? 0 : do_gline(cptr, sptr, gline);
456 gline_deactivate(struct Client *cptr, struct Client *sptr, struct Gline *gline,
457 time_t lastmod, unsigned int flags)
459 unsigned int saveflags = 0;
464 saveflags = gline->gl_flags;
466 if (GlineIsLocal(gline))
467 msg = "removing local";
468 else if (!gline->gl_lastmod && !(flags & GLINE_LOCAL)) {
469 msg = "removing global";
470 gline->gl_flags &= ~GLINE_ACTIVE; /* propagate a -<mask> */
472 msg = "deactivating global";
474 if (flags & GLINE_LOCAL)
475 gline->gl_flags |= GLINE_LDEACT;
477 gline->gl_flags &= ~GLINE_ACTIVE;
479 if (gline->gl_lastmod) {
480 if (gline->gl_lastmod >= lastmod)
483 gline->gl_lastmod = lastmod;
487 if ((saveflags & GLINE_ACTMASK) != GLINE_ACTIVE)
488 return 0; /* was inactive to begin with */
491 /* Inform ops and log it */
492 sendto_opmask_butone(0, SNO_GLINE, "%s %s %s for %s%s%s, expiring at %Tu: "
494 (feature_bool(FEAT_HIS_SNOTICES) || IsServer(sptr)) ?
496 cli_name((cli_user(sptr))->server),
497 msg, GlineIsBadChan(gline) ? "BADCHAN" : "GLINE",
498 gline->gl_user, GlineIsBadChan(gline) ? "" : "@",
499 GlineIsBadChan(gline) ? "" : gline->gl_host,
500 gline->gl_expire + TSoffset, gline->gl_reason);
502 log_write(LS_GLINE, L_INFO, LOG_NOSNOTICE,
503 "%#C %s %s for %s%s%s, expiring at %Tu: %s", sptr, msg,
504 GlineIsBadChan(gline) ? "BADCHAN" : "GLINE", gline->gl_user,
505 GlineIsBadChan(gline) ? "" : "@",
506 GlineIsBadChan(gline) ? "" : gline->gl_host,
507 gline->gl_expire + TSoffset, gline->gl_reason);
509 if (!(flags & GLINE_LOCAL)) /* don't propagate local changes */
510 gline_propagate(cptr, sptr, gline);
512 /* if it's a local gline or a Uworld gline (and not locally deactivated).. */
513 if (GlineIsLocal(gline) || (!gline->gl_lastmod && !(flags & GLINE_LOCAL)))
514 gline_free(gline); /* get rid of it */
520 gline_find(char *userhost, unsigned int flags)
523 struct Gline *sgline;
524 char *user, *host, *t_uh;
526 if (flags & (GLINE_BADCHAN | GLINE_ANY)) {
527 for (gline = BadChanGlineList; gline; gline = sgline) {
528 sgline = gline->gl_next;
530 if (gline->gl_expire <= CurrentTime)
532 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
533 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
535 else if ((flags & GLINE_EXACT ? ircd_strcmp(gline->gl_user, userhost) :
536 match(gline->gl_user, userhost)) == 0)
541 if ((flags & (GLINE_BADCHAN | GLINE_ANY)) == GLINE_BADCHAN ||
542 *userhost == '#' || *userhost == '&'
544 || userhost[2] == '#' || userhost[2] == '&'
545 #endif /* NO_OLD_GLINE */
549 DupString(t_uh, userhost);
550 canon_userhost(t_uh, &user, &host, 0);
555 for (gline = GlobalGlineList; gline; gline = sgline) {
556 sgline = gline->gl_next;
558 if (gline->gl_expire <= CurrentTime)
560 else if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
561 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
563 else if (flags & GLINE_EXACT) {
564 if (ircd_strcmp(gline->gl_host, host) == 0 &&
565 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
566 ircd_strcmp(gline->gl_user, user) == 0))
569 if (match(gline->gl_host, host) == 0 &&
570 ((!user && ircd_strcmp(gline->gl_user, "*") == 0) ||
571 match(gline->gl_user, user) == 0))
582 gline_lookup(struct Client *cptr, unsigned int flags)
585 struct Gline *sgline;
587 for (gline = GlobalGlineList; gline; gline = sgline) {
588 sgline = gline->gl_next;
590 if (gline->gl_expire <= CurrentTime) {
595 if ((flags & GLINE_GLOBAL && gline->gl_flags & GLINE_LOCAL) ||
596 (flags & GLINE_LASTMOD && !gline->gl_lastmod))
599 if (match(gline->gl_user, (cli_user(cptr))->username) != 0)
602 if (GlineIsIpMask(gline)) {
603 Debug((DEBUG_DEBUG,"IP gline: %08x %08x/%i",(cli_ip(cptr)).s_addr,gline->ipnum.s_addr,gline->bits));
604 if (((cli_ip(cptr)).s_addr & NETMASK(gline->bits)) != gline->ipnum.s_addr)
608 if (match(gline->gl_host, (cli_user(cptr))->realhost) != 0)
620 gline_free(struct Gline *gline)
624 *gline->gl_prev_p = gline->gl_next; /* squeeze this gline out */
626 gline->gl_next->gl_prev_p = gline->gl_prev_p;
628 MyFree(gline->gl_user); /* free up the memory */
630 MyFree(gline->gl_host);
631 MyFree(gline->gl_reason);
636 gline_burst(struct Client *cptr)
639 struct Gline *sgline;
641 for (gline = GlobalGlineList; gline; gline = sgline) { /* all glines */
642 sgline = gline->gl_next;
644 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
646 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
647 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s@%s %Tu %Tu :%s",
648 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
649 gline->gl_host, gline->gl_expire - CurrentTime,
650 gline->gl_lastmod, gline->gl_reason);
653 for (gline = BadChanGlineList; gline; gline = sgline) { /* all glines */
654 sgline = gline->gl_next;
656 if (gline->gl_expire <= CurrentTime) /* expire any that need expiring */
658 else if (!GlineIsLocal(gline) && gline->gl_lastmod)
659 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s %Tu %Tu :%s",
660 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
661 gline->gl_expire - CurrentTime, gline->gl_lastmod,
667 gline_resend(struct Client *cptr, struct Gline *gline)
669 if (GlineIsLocal(gline) || !gline->gl_lastmod)
672 sendcmdto_one(&me, CMD_GLINE, cptr, "* %c%s%s%s %Tu %Tu :%s",
673 GlineIsRemActive(gline) ? '+' : '-', gline->gl_user,
674 GlineIsBadChan(gline) ? "" : "@",
675 GlineIsBadChan(gline) ? "" : gline->gl_host,
676 gline->gl_expire - CurrentTime, gline->gl_lastmod,
683 gline_list(struct Client *sptr, char *userhost)
686 struct Gline *sgline;
689 if (!(gline = gline_find(userhost, GLINE_ANY))) /* no such gline */
690 return send_reply(sptr, ERR_NOSUCHGLINE, userhost);
692 /* send gline information along */
693 send_reply(sptr, RPL_GLIST, gline->gl_user,
694 GlineIsBadChan(gline) ? "" : "@",
695 GlineIsBadChan(gline) ? "" : gline->gl_host,
696 gline->gl_expire + TSoffset,
697 GlineIsLocal(gline) ? cli_name(&me) : "*",
698 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
700 for (gline = GlobalGlineList; gline; gline = sgline) {
701 sgline = gline->gl_next;
703 if (gline->gl_expire <= CurrentTime)
706 send_reply(sptr, RPL_GLIST, gline->gl_user, "@", gline->gl_host,
707 gline->gl_expire + TSoffset,
708 GlineIsLocal(gline) ? cli_name(&me) : "*",
709 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
712 for (gline = BadChanGlineList; gline; gline = sgline) {
713 sgline = gline->gl_next;
715 if (gline->gl_expire <= CurrentTime)
718 send_reply(sptr, RPL_GLIST, gline->gl_user, "", "",
719 gline->gl_expire + TSoffset,
720 GlineIsLocal(gline) ? cli_name(&me) : "*",
721 GlineIsActive(gline) ? '+' : '-', gline->gl_reason);
725 /* end of gline information */
726 return send_reply(sptr, RPL_ENDOFGLIST);
730 gline_stats(struct Client *sptr, struct StatDesc *sd, int stat,
734 struct Gline *sgline;
736 for (gline = GlobalGlineList; gline; gline = sgline) {
737 sgline = gline->gl_next;
739 if (gline->gl_expire <= CurrentTime)
742 send_reply(sptr, RPL_STATSGLINE, 'G', gline->gl_user, gline->gl_host,
743 gline->gl_expire + TSoffset, gline->gl_reason);
748 gline_memory_count(size_t *gl_size)
753 for (gline = GlobalGlineList; gline; gline = gline->gl_next)
756 *gl_size += sizeof(struct Gline);
757 *gl_size += gline->gl_user ? (strlen(gline->gl_user) + 1) : 0;
758 *gl_size += gline->gl_host ? (strlen(gline->gl_host) + 1) : 0;
759 *gl_size += gline->gl_reason ? (strlen(gline->gl_reason) + 1) : 0;