Hi Alex,

Ack, for the change as such. There should be a note in the function header 
informing that information fields has a max size and that information exceeding 
this size will be truncated.


Thanks

Lennart


________________________________
Från: Jones, Alex <ajo...@rbbn.com>
Skickat: den 17 januari 2019 20:27
Till: Hans Nordebäck; Lennart Lund; Anders Widell; Vu Minh Nguyen
Kopia: opensaf-devel@lists.sourceforge.net; Jones, Alex
Ämne: [PATCH 4/5] logd: fix truncation warnings [#2999]

---
src/log/logd/lgs_util.cc | 13 ++++---------
1 file changed, 4 insertions(+), 9 deletions(-)

diff --git a/src/log/logd/lgs_util.cc b/src/log/logd/lgs_util.cc
index 9b0707fd7..28b2a3271 100644
--- a/src/log/logd/lgs_util.cc
+++ b/src/log/logd/lgs_util.cc
@@ -199,19 +199,14 @@ char *lgs_get_time(time_t *time_in) {
osafassert(timeStampData);

stringSize = 5 * sizeof(char);
- if (snprintf(srcString, (size_t)stringSize, "%d",
- (timeStampData->tm_year + START_YEAR)) >=
- static_cast<int>(stringSize)) {
- LOG_WA("truncation on log year: %s", srcString);
- }
+ snprintf(srcString, (size_t)stringSize, "%u",
+ (timeStampData->tm_year + START_YEAR));

strncpy(timeStampString, srcString, stringSize);

stringSize = 3 * sizeof(char);
- if (snprintf(srcString, (size_t)stringSize, "%02d",
- timeStampData->tm_mon + 1) >= static_cast<int>(stringSize)) {
- LOG_WA("trunction on log month: %s", srcString);
- }
+ snprintf(srcString, (size_t)stringSize, "%02u",
+ timeStampData->tm_mon + 1);

strncat(timeStampString, srcString, stringSize);

--
2.17.2


________________________________
Notice: This e-mail together with any attachments may contain information of 
Ribbon Communications Inc. that is confidential and/or proprietary for the sole 
use of the intended recipient. Any review, disclosure, reliance or distribution 
by others or forwarding without express permission is strictly prohibited. If 
you are not the intended recipient, please notify the sender immediately and 
then delete all copies, including any attachments.
________________________________

_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to