Mercurial > pidgin
comparison libpurple/core.c @ 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 | 976a9b4c336a |
children | f9c369b4291c |
comparison
equal
deleted
inserted
replaced
16595:c992cdb19fa9 | 16596:99e786de5bd5 |
---|---|
399 { | 399 { |
400 /* We're only going to duplicate a logs symlink. */ | 400 /* We're only going to duplicate a logs symlink. */ |
401 if (!strcmp(entry, "logs")) | 401 if (!strcmp(entry, "logs")) |
402 { | 402 { |
403 char buf[MAXPATHLEN]; | 403 char buf[MAXPATHLEN]; |
404 | 404 size_t linklen; |
405 if (readlink(name, buf, sizeof(buf) - 1) == -1) | 405 |
406 if ((linklen = readlink(name, buf, sizeof(buf) - 1) == -1)) | |
406 { | 407 { |
407 purple_debug_error("core", "Error reading symlink %s: %s\n", | 408 purple_debug_error("core", "Error reading symlink %s: %s\n", |
408 name, strerror(errno)); | 409 name, strerror(errno)); |
409 g_free(name); | 410 g_free(name); |
410 g_dir_close(dir); | 411 g_dir_close(dir); |
411 g_free(status_file); | 412 g_free(status_file); |
412 g_free(old_user_dir); | 413 g_free(old_user_dir); |
413 return FALSE; | 414 return FALSE; |
414 } | 415 } |
415 buf[sizeof(buf) - 1] = '\0'; | 416 buf[linklen] = '\0'; |
416 | 417 |
417 logs_dir = g_strconcat(user_dir, G_DIR_SEPARATOR_S "logs", NULL); | 418 logs_dir = g_strconcat(user_dir, G_DIR_SEPARATOR_S "logs", NULL); |
418 | 419 |
419 if (!strcmp(buf, "../.purple/logs") || !strcmp(buf, logs_dir)) | 420 if (!strcmp(buf, "../.purple/logs") || !strcmp(buf, logs_dir)) |
420 { | 421 { |