Fossil

Check-in [0e9b58c8]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Increase the amount of randomness in the probe string used to initialize an SSH synchronization link.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 0e9b58c80c16e000f275b32edab066c943cd6d09
User & Date: drh 2012-11-12 15:12:05
Context
2012-11-12
15:22
Fix a boundary case in the SSH link startup logic. check-in: 5776dfad user: drh tags: trunk
15:12
Increase the amount of randomness in the probe string used to initialize an SSH synchronization link. check-in: 0e9b58c8 user: drh tags: trunk
15:01
Fix a link problem with the default skin and skin#5. check-in: 62c565ec user: drh tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to src/http_transport.c.

95
96
97
98
99
100
101











102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
...
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
** Default SSH command
*/
#ifdef __MINGW32__
static char zDefaultSshCmd[] = "ssh -T";
#else
static char zDefaultSshCmd[] = "ssh -e none -T";
#endif












/*
** Bring up an SSH link.  This involves sending some "echo" commands and
** get back appropriate responses.  The point is to move past the MOTD and
** verify that the link is working.
*/
static void transport_ssh_startup(void){
  char *zIn;         /* An input line received back from remote */
  int nWait;         /* Number of times waiting for the MOTD */
  unsigned iRandom;  /* Random probe value */
  char zProbe[30];   /* Text of the random probe */
  int nProbe;        /* Size of probe message */
  int nIn;                         /* Size of input */
  static const int nBuf = 10000;   /* Size of input buffer */

  zIn = fossil_malloc(nBuf);
  sqlite3_randomness(sizeof(iRandom), &iRandom);
  sqlite3_snprintf(sizeof(zProbe), zProbe, "probe-%08x", iRandom);
  nProbe = (int)strlen(zProbe);
  fprintf(sshOut, "echo %s\n", zProbe);
  fflush(sshOut);
  if( g.fSshTrace ){
    printf("Sent: [echo %s]\n", zProbe);
    fflush(stdout);
  }
  memset(zIn, '*', nProbe);
................................................................................
    nIn = (int)strlen(zIn);
    memcpy(zIn, zIn+(nIn-nProbe), nProbe);
    if( g.fSshTrace ){
      printf("Fetching more text.  Looking for [%s]...\n", zProbe);
      fflush(stdout);
    }
  }
  sqlite3_randomness(sizeof(iRandom), &iRandom);
  sqlite3_snprintf(sizeof(zProbe), zProbe, "probe-%08x", iRandom);
  fprintf(sshOut, "echo %s\n", zProbe);
  fflush(sshOut);
  if( g.fSshTrace ){
    printf("Sent: [echo %s]\n", zProbe);
    fflush(stdout);
  }
  sshin_read(zIn, nBuf);







>
>
>
>
>
>
>
>
>
>
>







|
|
<
|
|




|
<
<







 







|
<







95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121

122
123
124
125
126
127
128


129
130
131
132
133
134
135
...
146
147
148
149
150
151
152
153

154
155
156
157
158
159
160
** Default SSH command
*/
#ifdef __MINGW32__
static char zDefaultSshCmd[] = "ssh -T";
#else
static char zDefaultSshCmd[] = "ssh -e none -T";
#endif

/*
** Generate a random SSH link problem keyword
*/
static int random_probe(char *zProbe, int nProbe){
  unsigned r[4];
  sqlite3_randomness(sizeof(r), r);
  sqlite3_snprintf(nProbe, zProbe, "probe-%08x%08x%08x%08x",
                   r[0], r[1], r[2], r[3]);
  return (int)strlen(zProbe);
}

/*
** Bring up an SSH link.  This involves sending some "echo" commands and
** get back appropriate responses.  The point is to move past the MOTD and
** verify that the link is working.
*/
static void transport_ssh_startup(void){
  char *zIn;                       /* An input line received back from remote */
  int nWait;                       /* Number of times waiting for the MOTD */

  char zProbe[40];                 /* Text of the random probe */
  int nProbe;                      /* Size of probe message */
  int nIn;                         /* Size of input */
  static const int nBuf = 10000;   /* Size of input buffer */

  zIn = fossil_malloc(nBuf);
  nProbe = random_probe(zProbe, sizeof(zProbe));


  fprintf(sshOut, "echo %s\n", zProbe);
  fflush(sshOut);
  if( g.fSshTrace ){
    printf("Sent: [echo %s]\n", zProbe);
    fflush(stdout);
  }
  memset(zIn, '*', nProbe);
................................................................................
    nIn = (int)strlen(zIn);
    memcpy(zIn, zIn+(nIn-nProbe), nProbe);
    if( g.fSshTrace ){
      printf("Fetching more text.  Looking for [%s]...\n", zProbe);
      fflush(stdout);
    }
  }
  nProbe = random_probe(zProbe, sizeof(zProbe));

  fprintf(sshOut, "echo %s\n", zProbe);
  fflush(sshOut);
  if( g.fSshTrace ){
    printf("Sent: [echo %s]\n", zProbe);
    fflush(stdout);
  }
  sshin_read(zIn, nBuf);