The Samba-Bugzilla – Attachment 10858 Details for
Bug 11157
Always check the result of stat() system call
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Make sure to check the result of stat() call always.
0004-make-sure-the-result-of-stat-call-is-checked.patch (text/plain), 2.02 KB, created by
ishikawa
on 2015-03-11 15:57:08 UTC
(
hide
)
Description:
Make sure to check the result of stat() call always.
Filename:
MIME Type:
Creator:
ishikawa
Created:
2015-03-11 15:57:08 UTC
Size:
2.02 KB
patch
obsolete
>From 209d784d0e0c8fc40f9e18549e988ce19e254117 Mon Sep 17 00:00:00 2001 >From: Chiaki ISHIKAWA <ishikawa@yk.rim.or.jp> >Date: Tue, 10 Mar 2015 21:50:15 +0900 >Subject: [PATCH 4/8] make sure the result of stat() call is checked. > >--- > ccache.c | 28 ++++++++++++++++++++++++---- > 1 file changed, 24 insertions(+), 4 deletions(-) > >diff --git a/ccache.c b/ccache.c >index 44383d1..65e376a 100644 >--- a/ccache.c >+++ b/ccache.c >@@ -759,8 +759,15 @@ void update_manifest_file(void) > if (manifest_put(manifest_path, cached_obj_hash, included_files)) { > cc_log("Added object file hash to %s", manifest_path); > update_mtime(manifest_path); >- stat(manifest_path, &st); >- stats_update_size(file_size(&st) - old_size, old_size == 0 ? 1 : 0); >+ /* >+ * Don't forget to check the return value of stat and act accordingly. >+ */ >+ if (stat(manifest_path, &st) == 0) { >+ stats_update_size(file_size(&st) - old_size, old_size == 0 ? 1 : 0); >+ } else { >+ cc_log("stat on manifest (manifest_path) %s failed (%s), so size statistics is incorrect.", >+ manifest_path, strerror(errno)); >+ } > } else { > cc_log("Failed to add object file hash to %s", manifest_path); > } >@@ -908,9 +915,22 @@ to_cache(struct args *args) > } > cc_log("Stored in cache: %s", cached_stderr); > if (conf->compression) { >- stat(cached_stderr, &st); >+ /* >+ * The file was compressed, so obtain the compressed >+ * size again. >+ * >+ * Do not forget to check return value of stat() and act >+ * accordingly. >+ */ >+ if ( stat(cached_stderr, &st) == 0) { >+ stats_update_size(file_size(&st), 1); >+ } else { >+ cc_log("stat on cached_stderr=%s failed (%s)", >+ cached_stderr, strerror(errno)); >+ } >+ } else { >+ stats_update_size(file_size(&st), 1); > } >- stats_update_size(file_size(&st), 1); > } else { > tmp_unlink(tmp_stderr); > if (conf->recache) { >-- >2.1.4 >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 11157
:
10858
|
10882