bugGNU Screen - Bugs: bug #61534, long session names break screen...


bug #61534: long session names break screen with no error message/rails

Submitted by:  None
Submitted on:  Tue 23 Nov 2021 07:22:00 PM UTC
Category:  Program Logic Severity:  3 - Normal
Priority:  * 5 - Normal Status:  Fixed
Privacy:  Public Assigned to:  anaumov
Open/Closed:  Closed Release:  4.8.0
Fixed Release:  4.9.0 Planned Release:  4.9.0
Work Required:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:
       No canned response available


Fri 21 Jan 2022 01:27:32 PM UTC, comment #2: 

This patch is in git now.
I will close this bugreport now. If this patch doesn't fix the problem correctly, reopen it or create a new one.

Alexander Naumov <anaumov>
Project Administrator
Tue 11 Jan 2022 12:03:02 AM UTC, comment #1: 

Try this:

diff --git a/src/screen.c b/src/screen.c
index 1a22892..85959b1 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -778,6 +778,10 @@ int main(int ac, char** av)
               if (--ac == 0)
                 exit_with_usage(myname, "Specify session-name with -S", NULL);
               SockMatch = *++av;
+              debug1("SockMatch: '%s'\n", SockMatch);
+              debug1("SockMatch len: '%d'\n", (int)strlen(SockMatch));
+              if (strlen(SockMatch) > 80)
+                exit_with_usage(myname, "Session-name is too long (max length is 80 symbols)", NULL);
             if (!*SockMatch)
               exit_with_usage(myname, "Empty session-name?", NULL);
@@ -1203,6 +1207,13 @@ int main(int ac, char** av)
     SetTtyname(false, &st);
     if (!*av)
       Panic(0, "Please specify a command.");
+    if (!strcmp("sessionname", *av)) {
+      if (!*++av)
+        Panic(0, "Please specify a parameter.");
+      if (strlen(*av) > 80)
+        Panic(0, "Parameter of command 'sessionname' is too long.");
+    }
+    *--av;
     SendCmdMessage(sty, SockMatch, av, queryflag >= 0);

That's what I get:

$ ./screen -ls
No Sockets found in /tmp/uscreens/S-alex.

$ ./screen -S averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -d -m bash -c 'ping -c 600 localhost'
Use: ./screen [-opts] [cmd [args]]
 or: ./screen -r [host.tty]

-a            Force all capabilities into each window's termcap.
-A -[r|R]     Adapt all windows to the new display width & height.
-c file       Read configuration file instead of '.screenrc'.
-d (-r)       Detach the elsewhere running screen (and reattach here).
-dmS name     Start as daemon: Screen session in detached mode.
-D (-r)       Detach and logout remote (and reattach here).
-D -RR        Do whatever is needed to get a screen session.
-e xy         Change command characters.
-f            Flow control on, -fn = off, -fa = auto.
-h lines      Set the size of the scrollback history buffer.
-i            Interrupt output sooner when flow control is on.
-l            Login mode on (update /var/run/utmp), -ln = off.
-ls [match]   or
-list         Do nothing, just list our SockDir [on possible matches].
-L            Turn on output logging.
-Logfile file Set logfile name.
-m            ignore $STY variable, do create a new screen session.
-O            Choose optimal output rather than exact vt100 emulation.
-p window     Preselect the named window if it exists.
-q            Quiet startup. Exits with non-zero return code if unsuccessful.
-Q            Commands will send the response to the stdout of the querying process.
-r [session]  Reattach to a detached screen process.
-R            Reattach if possible, otherwise start a new session.
-s shell      Shell to execute rather than $SHELL.
-S sockname   Name this session <pid>.sockname instead of <pid>.<tty>.<host>.
-t title      Set title. (window's name).
-T term       Use term as $TERM for windows, rather than "screen".
-U            Tell screen to use UTF-8 encoding.
-v            Print "Screen version 4.09.00 (GNU) 07-Jan-22".
-wipe [match] Do nothing, just clean up SockDir [on possible matches].
-x            Attach to a not detached screen. (Multi display mode).
-X            Execute <cmd> as a screen command in the specified session.

Error: Session-name is too long (max length is 80 symbols)
$ echo $?

> ./screen -ls
No Sockets found in /tmp/uscreens/S-alex.

> ./screen -S averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -d -m bash -c 'ping -c 600 localhost'

$ ./screen -ls
There is a screen on:
        19381.averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa        (Detached)
1 Socket in /tmp/uscreens/S-alex.

$ ./screen -r averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

... I see the ping cmd... press Ctrl-C...

[screen is terminating]

$ echo $?

and the second case:

$ ./screen -ls
No Sockets found in /tmp/uscreens/S-alex.

$ ./screen -S shortname -d -m bash -c 'ping -c 600 localhost'

$ ./screen -ls
There is a screen on:
1 Socket in /tmp/uscreens/S-alex.

$ ./screen -S shortname -X sessionname averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Parameter of command 'sessionname' is too long.

$ echo $?

$ ./screen -S shortname -X sessionname averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

$ echo $?

$ ./screen -ls
There is a screen on:
        19318.averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa        (Detached)
1 Socket in /tmp/uscreens/S-alex.

$ ./screen -r 19318.averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa

... I see ping again... press Ctrl-C...

[screen is terminating]

Alexander Naumov <anaumov>
Project Administrator
Tue 23 Nov 2021 07:22:00 PM UTC, original submission:  

screen will allow you to specify a long session name without error, but does not work if your session name is too long.  For initial sessions, this causes there to be no session created, but no error:

jmcminn@dukhat:~$ screen -S averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa -d -m bash -c 'ping -c 600 localhost'
jmcminn@dukhat:~$ screen -ls
No Sockets found in /run/screen/S-jmcminn.


For renamed sessions, the rename command takes, but results in a "Dead" session that cannot be attached to or further interacted with:

jmcminn@dukhat:~$ screen -S shortname -d -m bash -c 'ping -c 600 localhost'
jmcminn@dukhat:~$ screen -ls
There is a screen on:
102297.shortname (11/23/2021 11:00:57 AM) (Detached)
1 Socket in /run/screen/S-jmcminn.
jmcminn@dukhat:~$ screen -S shortname -X sessionname averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
jmcminn@dukhat:~$ screen -ls
There is a screen on:
102297.averyverylongsesssionnameaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa (11/23/2021 11:00:58 AM) (Dead ???)
Remove dead screens with 'screen -wipe'.
1 Socket in /run/screen/S-jmcminn.



(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by anaumov (Updated the item)

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only logged-in users can vote.





    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-01-21 anaumov StatusReady For Test => Fixed
        Open/ClosedOpen => Closed
        Fixed ReleaseNone => 4.9.0
    2022-01-15 anaumov StatusConfirmed => Ready For Test
    2022-01-11 anaumov Assigned toNone => anaumov
        Planned ReleaseNone => 4.9.0
    2022-01-10 anaumov StatusNone => Confirmed

    Back to the top

    Powered by Savane 3.9