Skip to content
This repository was archived by the owner on May 6, 2020. It is now read-only.

Commit 61d82ea

Browse files
authored
Merge pull request #94 from jodh-intel/add-missing-vargs-call
Add missing vargs call
2 parents 841d6fe + 453042c commit 61d82ea

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/log.c

+12-5
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,8 @@ void shim_log(int priority, const char *func, int line_number, const char *forma
112112
return;
113113
}
114114

115+
va_end(vargs);
116+
115117
if (priority <= LOG_ERR) {
116118
fprintf(stderr, "%s:%d:%s\n", func, line_number, buf);
117119
}
@@ -123,13 +125,14 @@ void shim_log(int priority, const char *func, int line_number, const char *forma
123125
}
124126

125127
if (get_time_iso8601 (time_buffer, sizeof(time_buffer)) < 0) {
128+
/* log a blank time on error as something is better than
129+
* nothing (the system logger can still provide a timestamp).
130+
*/
126131
time_buffer[0] = '\0';
127132
}
128133

134+
/* Handle failure scenario below */
129135
quoted = quote_string(buf);
130-
if (! quoted) {
131-
return;
132-
}
133136

134137
syslog(priority, "time=\"%s\" level=\"%s\" pid=%d function=\"%s\" line=%d source=\"%s\" name=\"%s\" msg=\"%s\"",
135138
time_buffer,
@@ -139,8 +142,12 @@ void shim_log(int priority, const char *func, int line_number, const char *forma
139142
line_number,
140143
"shim",
141144
SHIM_NAME,
142-
quoted);
143-
va_end(vargs);
145+
146+
/* log the original message if it couldn't be quoted
147+
* (better than nothing)
148+
*/
149+
quoted ? quoted : buf);
150+
144151
free(buf);
145152
free(quoted);
146153
}

0 commit comments

Comments
 (0)