mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
psusan: fix assertion failure in SFTP server.
Uppity's built-in SFTP server makes up its file handle identifiers using random_read(). But when that server is reused in psusan, which doesn't have the random number generator enabled, you get an assertion failure.
This commit is contained in:
parent
9ea0dfd8c0
commit
3a9b7267dd
@ -132,3 +132,6 @@ int platform_make_x11_server(Plug *plug, const char *progname, int mindisp,
|
|||||||
Socket **sockets, Conf *conf);
|
Socket **sockets, Conf *conf);
|
||||||
|
|
||||||
Conf *make_ssh_server_conf(void);
|
Conf *make_ssh_server_conf(void);
|
||||||
|
|
||||||
|
/* Provided by Unix front end programs to uxsftpserver.c */
|
||||||
|
void make_unix_sftp_filehandle_key(void *data, size_t size);
|
||||||
|
@ -84,6 +84,16 @@ void timer_change_notify(unsigned long next)
|
|||||||
|
|
||||||
char *platform_get_x_display(void) { return NULL; }
|
char *platform_get_x_display(void) { return NULL; }
|
||||||
|
|
||||||
|
void make_unix_sftp_filehandle_key(void *vdata, size_t size)
|
||||||
|
{
|
||||||
|
/* psusan runs without a random number generator, so we can't make
|
||||||
|
* this up by random_read. Fortunately, psusan is also
|
||||||
|
* non-adversarial, so it's safe to generate this trivially. */
|
||||||
|
unsigned char *data = (unsigned char *)vdata;
|
||||||
|
for (size_t i = 0; i < size; i++)
|
||||||
|
data[i] = (unsigned)rand() / ((unsigned)RAND_MAX / 256);
|
||||||
|
}
|
||||||
|
|
||||||
static bool verbose;
|
static bool verbose;
|
||||||
|
|
||||||
struct server_instance {
|
struct server_instance {
|
||||||
|
@ -103,6 +103,11 @@ void timer_change_notify(unsigned long next)
|
|||||||
|
|
||||||
char *platform_get_x_display(void) { return NULL; }
|
char *platform_get_x_display(void) { return NULL; }
|
||||||
|
|
||||||
|
void make_unix_sftp_filehandle_key(void *data, size_t size)
|
||||||
|
{
|
||||||
|
random_read(data, size);
|
||||||
|
}
|
||||||
|
|
||||||
static bool verbose;
|
static bool verbose;
|
||||||
|
|
||||||
struct AuthPolicyShared {
|
struct AuthPolicyShared {
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "putty.h"
|
#include "putty.h"
|
||||||
#include "ssh.h"
|
#include "ssh.h"
|
||||||
|
#include "sshserver.h"
|
||||||
#include "sftp.h"
|
#include "sftp.h"
|
||||||
#include "tree234.h"
|
#include "tree234.h"
|
||||||
|
|
||||||
@ -65,7 +66,7 @@ static SftpServer *uss_new(const SftpServerVtable *vt)
|
|||||||
uss->dirhandles = newtree234(uss_dirhandle_cmp);
|
uss->dirhandles = newtree234(uss_dirhandle_cmp);
|
||||||
uss->srv.vt = vt;
|
uss->srv.vt = vt;
|
||||||
|
|
||||||
random_read(uss->handlekey, sizeof(uss->handlekey));
|
make_unix_sftp_filehandle_key(uss->handlekey, sizeof(uss->handlekey));
|
||||||
|
|
||||||
return &uss->srv;
|
return &uss->srv;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user