diff options
author | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-18 18:01:24 +0000 |
---|---|---|
committer | michael <michael@82007160-df01-0410-b94d-b575c5fd34c7> | 2013-06-18 18:01:24 +0000 |
commit | 32e09a2ff52f692e63fb63c12054d8b98d60343e (patch) | |
tree | dc29086089c9e0bfe3251b1c9f0bdd4a4291b1ce | |
parent | c585460480429ac628b89b4d4cbef17514817858 (diff) |
- s_serv.c: cleanup show_capabilities(). Replace sprintf() combo with strlcat()
git-svn-id: svn://svn.ircd-hybrid.org/svnroot/ircd-hybrid/branches/8.1.x@2281 82007160-df01-0410-b94d-b575c5fd34c7
-rw-r--r-- | include/s_serv.h | 2 | ||||
-rw-r--r-- | src/s_serv.c | 17 |
2 files changed, 9 insertions, 10 deletions
diff --git a/include/s_serv.h b/include/s_serv.h index 60c6feb..f761dff 100644 --- a/include/s_serv.h +++ b/include/s_serv.h @@ -92,7 +92,7 @@ extern void send_capabilities(struct Client *, int); extern void write_links_file(void *); extern void read_links_file(void); extern void server_estab(struct Client *); -extern const char *show_capabilities(struct Client *); +extern const char *show_capabilities(const struct Client *); extern void try_connections(void *); extern void burst_channel(struct Client *client_p, struct Channel *); extern void sendnick_TS(struct Client *, struct Client *); diff --git a/src/s_serv.c b/src/s_serv.c index 8594bd2..5f09a09 100644 --- a/src/s_serv.c +++ b/src/s_serv.c @@ -638,23 +638,22 @@ sendnick_TS(struct Client *client_p, struct Client *target_p) * side effects - build up string representing capabilities of server listed */ const char * -show_capabilities(struct Client *target_p) +show_capabilities(const struct Client *target_p) { - static char msgbuf[IRCD_BUFSIZE]; - char *t = msgbuf; - dlink_node *ptr; - - t += sprintf(msgbuf, "TS "); + static char msgbuf[IRCD_BUFSIZE] = "TS"; + const dlink_node *ptr = NULL; DLINK_FOREACH(ptr, cap_list.head) { const struct Capability *cap = ptr->data; - if (IsCapable(target_p, cap->cap)) - t += sprintf(t, "%s ", cap->name); + if (!IsCapable(target_p, cap->cap)) + continue; + + strlcat(msgbuf, " ", sizeof(msgbuf)); + strlcat(msgbuf, cap->name, sizeof(msgbuf)); } - *(t - 1) = '\0'; return msgbuf; } |