diff options
author | LemonBoy <thatlemon@gmail.com> | 2016-02-13 13:18:24 +0100 |
---|---|---|
committer | LemonBoy <thatlemon@gmail.com> | 2016-06-05 16:24:55 +0200 |
commit | 72712a0c62b0403f0fa472ccbe34fda8fb2cd530 (patch) | |
tree | 54b053fa85d0630ff04f5f8e65843fe14a85e00a /src | |
parent | 8289f360757870b56a15576a20e79e1f2ca30fef (diff) | |
download | irssi-72712a0c62b0403f0fa472ccbe34fda8fb2cd530.zip |
Replace strocpy with g_strlcpy
The only difference was that the former returned 1 if the buffer was
overflown, but the return value was never checked.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/misc.c | 14 | ||||
-rw-r--r-- | src/core/misc.h | 3 | ||||
-rw-r--r-- | src/irc/core/irc-nicklist.c | 2 | ||||
-rw-r--r-- | src/irc/dcc/dcc-get.c | 6 |
4 files changed, 4 insertions, 21 deletions
diff --git a/src/core/misc.c b/src/core/misc.c index a8a0975a..682d006c 100644 --- a/src/core/misc.c +++ b/src/core/misc.c @@ -773,20 +773,6 @@ char *escape_string(const char *str) return ret; } -int strocpy(char *dest, const char *src, size_t dstsize) -{ - if (dstsize == 0) - return -1; - - while (*src != '\0' && dstsize > 1) { - *dest++ = *src++; - dstsize--; - } - - *dest++ = '\0'; - return *src == '\0' ? 0 : -1; -} - int nearest_power(int num) { int n = 1; diff --git a/src/core/misc.h b/src/core/misc.h index 58b665bf..fdb16a49 100644 --- a/src/core/misc.h +++ b/src/core/misc.h @@ -83,9 +83,6 @@ int parse_size(const char *size, int *bytes); Stop when `end_char' is found from string. */ int is_numeric(const char *str, char end_char); -/* Like strlcpy(), but return -1 if buffer was overflown, 0 if not. */ -int strocpy(char *dest, const char *src, size_t dstsize); - /* strstr() with case-ignoring */ char *stristr(const char *data, const char *key); diff --git a/src/irc/core/irc-nicklist.c b/src/irc/core/irc-nicklist.c index bcb9d1f6..b22f3269 100644 --- a/src/irc/core/irc-nicklist.c +++ b/src/irc/core/irc-nicklist.c @@ -48,7 +48,7 @@ NICK_REC *irc_nicklist_insert(IRC_CHANNEL_REC *channel, const char *nick, rec->send_massjoin = send_massjoin; if (prefixes != NULL) { - strocpy(rec->prefixes, prefixes, sizeof(rec->prefixes)); + g_strlcpy(rec->prefixes, prefixes, sizeof(rec->prefixes)); } nicklist_insert(CHANNEL(channel), rec); diff --git a/src/irc/dcc/dcc-get.c b/src/irc/dcc/dcc-get.c index ac281683..e7b796bb 100644 --- a/src/irc/dcc/dcc-get.c +++ b/src/irc/dcc/dcc-get.c @@ -473,8 +473,8 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data, net_ip2host(&temp_dcc->addr, temp_dcc->addrstr); else { /* with IPv6, show it to us as it was sent */ - strocpy(temp_dcc->addrstr, address, - sizeof(temp_dcc->addrstr)); + g_strlcpy(temp_dcc->addrstr, address, + sizeof(temp_dcc->addrstr)); } /* This new signal is added to let us invoke @@ -508,7 +508,7 @@ static void ctcp_msg_dcc_send(IRC_SERVER_REC *server, const char *data, net_ip2host(&dcc->addr, dcc->addrstr); else { /* with IPv6, show it to us as it was sent */ - strocpy(dcc->addrstr, address, sizeof(dcc->addrstr)); + g_strlcpy(dcc->addrstr, address, sizeof(dcc->addrstr)); } dcc->port = port; dcc->size = size; |