Bug 61961

Summary: Shell escape commands garbled
Product: [Retired] Red Hat Public Beta Reporter: Klaus-J. Wolf <klaus-juergen.wolf>
Component: ncftpAssignee: Bernhard Rosenkraenzer <bero>
Status: CLOSED RAWHIDE QA Contact: Ben Levenson <benl>
Severity: medium Docs Contact:
Priority: medium    
Version: skipjack-beta1CC: bero, kjwolf
Target Milestone: ---   
Target Release: ---   
Hardware: i386   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-04-05 11:39:08 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On:    
Bug Blocks: 61901    

Description Klaus-J. Wolf 2002-03-26 10:02:32 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; T312461)

Description of problem:
When trying to use a shell escape command, ncftp outputs some trash string 
appended with ": no such command".

Version-Release number of selected component (if applicable):


How reproducible:
Always

Steps to Reproduce:
1. Enter ncftp
2. Enter !ls
3.
	

Actual Results:  Output: (trash string): no such command.

Expected Results:  Directory output.

Additional info:

Comment 1 Bernhard Rosenkraenzer 2002-03-27 20:20:02 UTC
This appears to be a stdio handling bug, since the following patch works 
around the problem: 
 
--- ncftp-3.1.3/ncftp/shell.c.foo       Wed Mar 27 21:14:03 2002 
+++ ncftp-3.1.3/ncftp/shell.c   Wed Mar 27 21:15:23 2002 
@@ -572,6 +572,7 @@ 
                oldcount = gUserTypedSensitiveInfoAtShellSoDoNotSaveItToDisk; 
                for (tUsed = 0;;) { 
                        (void) memset(&ai, 0, sizeof(ai)); 
+                       fflush(stdout); 
                        bUsed = MakeArgv(lineRead + tUsed, &ai.cargc, 
ai.cargv, 
                                (int) (sizeof(ai.cargv) / sizeof(char *)), 
                                ai.argbuf, sizeof(ai.argbuf), 
 
 
 
 
 
 
Adding this patch to ncftp to cure the symptoms for now.

Comment 2 Jakub Jelinek 2002-04-05 11:39:03 UTC
It is just a workaround, the bug is in ncftp.
Using pointer to xclam local variable after the function containing it
exited is really bad idea:

--- shell.c.xx  Wed Mar 27 11:34:58 2002
+++ shell.c     Fri Apr  5 13:40:38 2002
@@ -225,13 +225,14 @@ MakeArgv(char *line, int *cargc, char **
        char *dcp;
        char *scp;
        char *arg;
-       char xclam[4];
+       char *xclam;

        *cargc = 0;
        scp = line;
-       dlim = dbuf + dbufsize - 1;
+       dlim = dbuf + dbufsize - 3;
        dcp = dbuf;

+       xclam = dlim + 1;
        xclam[0] = '!';
        xclam[1] = '\0';

Either above patch, or, if nobody ever writes into *cargv[0], which would
very surprise me, even better:

--- shell.c.xx  Wed Mar 27 11:34:58 2002
+++ shell.c     Fri Apr  5 13:44:40 2002
@@ -225,16 +225,12 @@ MakeArgv(char *line, int *cargc, char **
        char *dcp;
        char *scp;
        char *arg;
-       char xclam[4];

        *cargc = 0;
        scp = line;
        dlim = dbuf + dbufsize - 1;
        dcp = dbuf;

-       xclam[0] = '!';
-       xclam[1] = '\0';
-
        for (*cargc = 0; *cargc < cargcmax; ) {
                /* Eat preceding junk. */
                for ( ; ; scp++) {
@@ -260,7 +256,7 @@ MakeArgv(char *line, int *cargc, char **
                        if (scp[1] == '!') {
                                scp[1] = '\0';
                        } else if ((scp[1] != '\0') && (!isspace((int) scp[1]))) {
-                               cargv[0] = xclam;
+                               cargv[0] = "!";
                                scp++;
                                arg = dcp;
                                cargv[*cargc] = arg;

Both patches worked just fine for me.

Comment 3 Florian La Roche 2002-04-10 18:58:48 UTC
I have just built a 3.1.3-3 version with the second version of Jakub's proposal.

cu,

Florian La Roche