Bug 61961 - Shell escape commands garbled
Shell escape commands garbled
Status: CLOSED RAWHIDE
Product: Red Hat Public Beta
Classification: Retired
Component: ncftp (Show other bugs)
skipjack-beta1
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Bernhard Rosenkraenzer
Ben Levenson
:
Depends On:
Blocks: 61901
  Show dependency treegraph
 
Reported: 2002-03-26 05:02 EST by Klaus-J. Wolf
Modified: 2007-04-18 12:41 EDT (History)
2 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2002-04-05 06:39:08 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Klaus-J. Wolf 2002-03-26 05:02:32 EST
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 15:20:02 EST
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 06:39:03 EST
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 14:58:48 EDT
I have just built a 3.1.3-3 version with the second version of Jakub's proposal.

cu,

Florian La Roche

Note You need to log in before you can comment on or make changes to this bug.