diff --git a/src/openvpnserv/interactive.c b/src/openvpnserv/interactive.c
index 24705a9..32b1688 100644
--- a/src/openvpnserv/interactive.c
+++ b/src/openvpnserv/interactive.c
@@ -2256,7 +2256,12 @@
         {
             if (i != 0)
             {
-                /* Add separator */
+                /* Add separator, if there is room for more than the terminator */
+                if (s < 2)
+                {
+                    *size = 0;
+                    return ERROR_MORE_DATA;
+                }
                 *pos++ = ',';
                 s--;
             }
