Mercurial > pidgin
changeset 16596:99e786de5bd5
#386: readlink does not append NUL to the end of buffer
committer: Sadrul Habib Chowdhury <imadil@gmail.com>
author | Ka-Hing Cheung <khc@hxbc.us> |
---|---|
date | Sat, 28 Apr 2007 23:25:43 +0000 |
parents | c992cdb19fa9 |
children | 2ddffaf3613a |
files | libpurple/core.c |
diffstat | 1 files changed, 3 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/core.c Sat Apr 28 22:52:42 2007 +0000 +++ b/libpurple/core.c Sat Apr 28 23:25:43 2007 +0000 @@ -401,8 +401,9 @@ if (!strcmp(entry, "logs")) { char buf[MAXPATHLEN]; + size_t linklen; - if (readlink(name, buf, sizeof(buf) - 1) == -1) + if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1)) { purple_debug_error("core", "Error reading symlink %s: %s\n", name, strerror(errno)); @@ -412,7 +413,7 @@ g_free(old_user_dir); return FALSE; } - buf[sizeof(buf) - 1] = '\0'; + buf[linklen] = '\0'; logs_dir = g_strconcat(user_dir, G_DIR_SEPARATOR_S "logs", NULL);