summaryrefslogtreecommitdiffstats
path: root/status.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-07-18 07:15:27 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-07-18 07:15:27 +0000
commit6cd276ba3fced973e5006ccabcb51d5734721914 (patch)
tree4e0c3b9f0d2020e983387107457b3731b4650cad /status.c
parentddad0a8c23560ba39b786144d8b74be8b8ffd64f (diff)
downloadopenvpn-6cd276ba3fced973e5006ccabcb51d5734721914.tar.gz
openvpn-6cd276ba3fced973e5006ccabcb51d5734721914.tar.xz
openvpn-6cd276ba3fced973e5006ccabcb51d5734721914.zip
status_printf function will now set error flag on
output truncation or failure of write() to write the expected number of bytes. 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
Diffstat (limited to 'status.c')
-rw-r--r--status.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/status.c b/status.c
index 2cf2611..368f9a7 100644
--- a/status.c
+++ b/status.c
@@ -212,7 +212,7 @@ status_close (struct status_output *so)
return ret;
}
-#define STATUS_PRINTF_MAXLEN 256
+#define STATUS_PRINTF_MAXLEN 512
void
status_printf (struct status_output *so, const char *format, ...)
@@ -221,28 +221,32 @@ status_printf (struct status_output *so, const char *format, ...)
{
char buf[STATUS_PRINTF_MAXLEN+2]; /* leave extra bytes for CR, LF */
va_list arglist;
+ int stat;
va_start (arglist, format);
- vsnprintf (buf, STATUS_PRINTF_MAXLEN, format, arglist);
+ stat = vsnprintf (buf, STATUS_PRINTF_MAXLEN, format, arglist);
va_end (arglist);
buf[STATUS_PRINTF_MAXLEN - 1] = 0;
- if (so->msglevel >= 0)
+ if (stat < 0 || stat >= STATUS_PRINTF_MAXLEN)
+ so->errors = true;
+
+ if (so->msglevel >= 0 && !so->errors)
msg (so->msglevel, "%s", buf);
- if (so->fd >= 0)
+ if (so->fd >= 0 && !so->errors)
{
int len;
strcat (buf, "\n");
len = strlen (buf);
if (len > 0)
{
- if (write (so->fd, buf, len) < 0)
+ if (write (so->fd, buf, len) != len)
so->errors = true;
}
}
- if (so->vout)
+ if (so->vout && !so->errors)
{
chomp (buf);
(*so->vout->func) (so->vout->arg, so->vout->flags_default, buf);