osaf/tools/safimm/immcfg/imm_import.cc |  15 +++++++++++++--
 1 files changed, 13 insertions(+), 2 deletions(-)


With long DN, log format can go over 1024 bytes. The patch handles long log 
format, and allocate enough memory for the log format.

diff --git a/osaf/tools/safimm/immcfg/imm_import.cc 
b/osaf/tools/safimm/immcfg/imm_import.cc
--- a/osaf/tools/safimm/immcfg/imm_import.cc
+++ b/osaf/tools/safimm/immcfg/imm_import.cc
@@ -441,6 +441,7 @@ static int base64_decode(char *in, char 
 static void log_stderr_int(int priority, const char *format, va_list args)
 {
        char log_string[1024];
+       char *log_str = log_string;
 
        if (priority == LOG_INFO && !imm_import_verbose) {
                // only printout INFO statements if -v (verbose) flag is set
@@ -449,11 +450,21 @@ static void log_stderr_int(int priority,
 
        /* Add line feed if not there already */
        if (format[strlen(format) - 1] != '\n') {
-               sprintf(log_string, "%s\n", format);
-               format = log_string;
+               int size = snprintf(log_str, 1024, "%s\n", format);
+               if(size >= 1024) {
+                       /* if format cannot fit in log_string,
+                        * then we need to allocate enough memory for the 
format */
+                       log_str = (char *)malloc(size + 1);
+                       sprintf(log_str, "%s\n", format);
+               }
+               format = log_str;
        }
 
        vfprintf(stderr, format, args);
+
+       if(log_str != log_string) {
+               free(log_str);
+       }
 }
 
 static void log_stderr(int priority, const char *format, ...)

------------------------------------------------------------------------------
Meet PCI DSS 3.0 Compliance Requirements with EventLog Analyzer
Achieve PCI DSS 3.0 Compliant Status with Out-of-the-box PCI DSS Reports
Are you Audit-Ready for PCI DSS 3.0 Compliance? Download White paper
Comply to PCI DSS 3.0 Requirement 10 and 11.5 with EventLog Analyzer
http://pubads.g.doubleclick.net/gampad/clk?id=154622311&iu=/4140/ostg.clktrk
_______________________________________________
Opensaf-devel mailing list
Opensaf-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/opensaf-devel

Reply via email to