diff --git a/java/com/turbovnc/vncviewer/SessionManager.java b/java/com/turbovnc/vncviewer/SessionManager.java index 03aa9dece..d2a18bdd6 100644 --- a/java/com/turbovnc/vncviewer/SessionManager.java +++ b/java/com/turbovnc/vncviewer/SessionManager.java @@ -113,7 +113,18 @@ private static String[] getSessions(Session sshSession, String host) if (!result.startsWith("[TURBOVNC] ")) continue; result = result.replace("[TURBOVNC] ", ""); if (error == null && result.length() > 0) error = result; - sessions = result.split(" "); + String[] splitResult = result.split("\t"); + if (splitResult.length >= 2) { + int numSessions = Integer.parseInt(splitResult[0]); + int numFields = Integer.parseInt(splitResult[1]); + if (numSessions > 0 && numFields > 0 && + splitResult.length == numSessions * numFields + 2) { + ArrayList sessionList = new ArrayList(); + for (int index = 2; index < splitResult.length; index += numFields) + sessionList.add(splitResult[index]); + sessions = sessionList.toArray(new String[numSessions]); + } + } break; } diff --git a/unix/vncserver.in b/unix/vncserver.in index 9f78496b1..eaa7b4f45 100644 --- a/unix/vncserver.in +++ b/unix/vncserver.in @@ -1,6 +1,6 @@ #!/usr/bin/perl # -# Copyright (C) 2009-2018 D. R. Commander. All Rights Reserved. +# Copyright (C) 2009-2018, 2020 D. R. Commander. All Rights Reserved. # Copyright (C) 2010 University Corporation for Atmospheric Research. # All Rights Reserved. # Copyright (C) 2005-2006 Sun Microsystems, Inc. All Rights Reserved. @@ -890,10 +890,13 @@ sub SessionList } if (scalar(@sessions)) { @sessions = sort { $a <=> $b } @sessions; + print scalar(@sessions)."\t1\t"; foreach my $session (@sessions) { - print ":".$session." "; + print ":".$session."\t"; } print "\n"; + } else { + print "0\t1\n"; } exit; }