# HG changeset patch # User Ka-Hing Cheung # Date 1177802743 0 # Node ID 99e786de5bd52069327b48994b7fa25482d7a681 # Parent c992cdb19fa93fc65ff58c5bd35b5a836c237c9b #386: readlink does not append NUL to the end of buffer committer: Sadrul Habib Chowdhury diff -r c992cdb19fa9 -r 99e786de5bd5 libpurple/core.c --- 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);