Raised STATUS_PRINTF_MAXLEN to 512 (from 256).
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3077 e7ae566f-a301-0410-adde-c780ea21d3b5
... | ... |
@@ -439,7 +439,7 @@ init_static (void) |
439 | 439 |
return false; |
440 | 440 |
#endif |
441 | 441 |
|
442 |
-#if 0 |
|
442 |
+#ifdef GEN_PATH_TEST |
|
443 | 443 |
{ |
444 | 444 |
struct gc_arena gc = gc_new (); |
445 | 445 |
const char *fn = gen_path ("foo", |
... | ... |
@@ -448,7 +448,20 @@ init_static (void) |
448 | 448 |
printf ("%s\n", fn); |
449 | 449 |
gc_free (&gc); |
450 | 450 |
} |
451 |
+ return false; |
|
452 |
+#endif |
|
451 | 453 |
|
454 |
+#ifdef STATUS_PRINTF_TEST |
|
455 |
+ { |
|
456 |
+ struct gc_arena gc = gc_new (); |
|
457 |
+ const char *tmp_file = create_temp_filename ("/tmp", "foo", &gc); |
|
458 |
+ struct status_output *so = status_open (tmp_file, 0, -1, NULL, STATUS_OUTPUT_WRITE); |
|
459 |
+ status_printf (so, "%s", "foo"); |
|
460 |
+ status_printf (so, "%s", "bar"); |
|
461 |
+ if (!status_close (so)) |
|
462 |
+ msg (M_WARN, "STATUS_PRINTF_TEST: %s: write error", tmp_file); |
|
463 |
+ gc_free (&gc); |
|
464 |
+ } |
|
452 | 465 |
return false; |
453 | 466 |
#endif |
454 | 467 |
|
... | ... |
@@ -212,7 +212,7 @@ status_close (struct status_output *so) |
212 | 212 |
return ret; |
213 | 213 |
} |
214 | 214 |
|
215 |
-#define STATUS_PRINTF_MAXLEN 256 |
|
215 |
+#define STATUS_PRINTF_MAXLEN 512 |
|
216 | 216 |
|
217 | 217 |
void |
218 | 218 |
status_printf (struct status_output *so, const char *format, ...) |
... | ... |
@@ -221,28 +221,32 @@ status_printf (struct status_output *so, const char *format, ...) |
221 | 221 |
{ |
222 | 222 |
char buf[STATUS_PRINTF_MAXLEN+2]; /* leave extra bytes for CR, LF */ |
223 | 223 |
va_list arglist; |
224 |
+ int stat; |
|
224 | 225 |
|
225 | 226 |
va_start (arglist, format); |
226 |
- vsnprintf (buf, STATUS_PRINTF_MAXLEN, format, arglist); |
|
227 |
+ stat = vsnprintf (buf, STATUS_PRINTF_MAXLEN, format, arglist); |
|
227 | 228 |
va_end (arglist); |
228 | 229 |
buf[STATUS_PRINTF_MAXLEN - 1] = 0; |
229 | 230 |
|
230 |
- if (so->msglevel >= 0) |
|
231 |
+ if (stat < 0 || stat >= STATUS_PRINTF_MAXLEN) |
|
232 |
+ so->errors = true; |
|
233 |
+ |
|
234 |
+ if (so->msglevel >= 0 && !so->errors) |
|
231 | 235 |
msg (so->msglevel, "%s", buf); |
232 | 236 |
|
233 |
- if (so->fd >= 0) |
|
237 |
+ if (so->fd >= 0 && !so->errors) |
|
234 | 238 |
{ |
235 | 239 |
int len; |
236 | 240 |
strcat (buf, "\n"); |
237 | 241 |
len = strlen (buf); |
238 | 242 |
if (len > 0) |
239 | 243 |
{ |
240 |
- if (write (so->fd, buf, len) < 0) |
|
244 |
+ if (write (so->fd, buf, len) != len) |
|
241 | 245 |
so->errors = true; |
242 | 246 |
} |
243 | 247 |
} |
244 | 248 |
|
245 |
- if (so->vout) |
|
249 |
+ if (so->vout && !so->errors) |
|
246 | 250 |
{ |
247 | 251 |
chomp (buf); |
248 | 252 |
(*so->vout->func) (so->vout->arg, so->vout->flags_default, buf); |