[clinfo] 16/36: Use snprintf+bufcpy in device_info_time_offset
Andreas Beckmann
anbe at moszumanska.debian.org
Wed Feb 17 18:32:37 UTC 2016
This is an automated email from the git hooks/post-receive script.
anbe pushed a commit to branch master
in repository clinfo.
commit d8b1e6c13d1c4c545de68f7e24219dae2178f39e
Author: Giuseppe Bilotta <giuseppe.bilotta at gmail.com>
Date: Wed Dec 9 18:14:34 2015 +0100
Use snprintf+bufcpy in device_info_time_offset
This should avoid warnings about use of dangerous functions such as
sprintf or strcpy.
---
src/clinfo.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/src/clinfo.c b/src/clinfo.c
index a43aff3..afcdeb5 100644
--- a/src/clinfo.c
+++ b/src/clinfo.c
@@ -876,13 +876,12 @@ int device_info_time_offset(cl_device_id dev, cl_device_info param, const char *
cl_ulong val = 0;
GET_VAL;
if (!had_error) {
- int szval = 0;
+ size_t szval = 0;
time_t time = val/UINT64_C(1000000000);
- szval += sprintf(strbuf, "%" PRIu64 "ns (", val);
- strcpy(strbuf + szval, ctime(&time));
- szval = strlen(strbuf) - 1;
- strbuf[szval++] = ')';
- strbuf[szval++] = '\0';
+ szval += snprintf(strbuf, bufsz, "%" PRIu64 "ns (", val);
+ szval += bufcpy(szval, ctime(&time));
+ if (szval < bufsz)
+ strbuf[szval] = ')';
}
show_strbuf(pname, 0);
return had_error;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-opencl/clinfo.git
More information about the Pkg-opencl-commits
mailing list