mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Revise the API for seat_stripctrl_new.
Now instead of taking raw arguments to configure the output StripCtrlChars with, it takes an enumerated value giving the context of what's being sanitised, and allows the seat to decide what the output parameters for that context should be. The only context currently used is SIC_BANNER (SSH login banners). I've also added a not-yet-used one for keyboard-interactive prompts.
This commit is contained in:
parent
d049f0ab6c
commit
d05d2e259f
2
misc.c
2
misc.c
@ -334,7 +334,7 @@ bool nullseat_get_windowid(Seat *seat, long *id_out) { return false; }
|
||||
bool nullseat_get_window_pixel_size(
|
||||
Seat *seat, int *width, int *height) { return false; }
|
||||
StripCtrlChars *nullseat_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs, bool cr, wchar_t sub) { return NULL; }
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic) {return NULL;}
|
||||
|
||||
void sk_free_peer_info(SocketPeerInfo *pi)
|
||||
{
|
||||
|
20
putty.h
20
putty.h
@ -740,6 +740,10 @@ typedef enum BusyStatus {
|
||||
* suspended */
|
||||
} BusyStatus;
|
||||
|
||||
typedef enum SeatInteractionContext {
|
||||
SIC_BANNER, SIC_KI_PROMPTS
|
||||
} SeatInteractionContext;
|
||||
|
||||
/*
|
||||
* Data type 'Seat', which is an API intended to contain essentially
|
||||
* everything that a back end might need to talk to its client for:
|
||||
@ -937,8 +941,8 @@ struct SeatVtable {
|
||||
* user of this seat. May return NULL if no sanitisation is
|
||||
* needed.
|
||||
*/
|
||||
StripCtrlChars *(*stripctrl_new)(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution);
|
||||
StripCtrlChars *(*stripctrl_new)(
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic);
|
||||
};
|
||||
|
||||
static inline size_t seat_output(
|
||||
@ -980,8 +984,8 @@ static inline bool seat_get_windowid(Seat *seat, long *id_out)
|
||||
static inline bool seat_get_window_pixel_size(Seat *seat, int *w, int *h)
|
||||
{ return seat->vt->get_window_pixel_size(seat, w, h); }
|
||||
static inline StripCtrlChars *seat_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs, bool cr, wchar_t sub)
|
||||
{ return seat->vt->stripctrl_new(seat, bs, cr, sub); }
|
||||
Seat *seat, BinarySink *bs, SeatInteractionContext sic)
|
||||
{ return seat->vt->stripctrl_new(seat, bs, sic); }
|
||||
|
||||
/* Unlike the seat's actual method, the public entry point
|
||||
* seat_connection_fatal is a wrapper function with a printf-like API,
|
||||
@ -1030,8 +1034,8 @@ void nullseat_echoedit_update(Seat *seat, bool echoing, bool editing);
|
||||
const char *nullseat_get_x_display(Seat *seat);
|
||||
bool nullseat_get_windowid(Seat *seat, long *id_out);
|
||||
bool nullseat_get_window_pixel_size(Seat *seat, int *width, int *height);
|
||||
StripCtrlChars *nullseat_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution);
|
||||
StripCtrlChars *nullseat_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic);
|
||||
|
||||
/*
|
||||
* Seat functions provided by the platform's console-application
|
||||
@ -1049,8 +1053,8 @@ int console_confirm_weak_crypto_primitive(
|
||||
int console_confirm_weak_cached_hostkey(
|
||||
Seat *seat, const char *algname, const char *betteralgs,
|
||||
void (*callback)(void *ctx, int result), void *ctx);
|
||||
StripCtrlChars *console_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution);
|
||||
StripCtrlChars *console_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic);
|
||||
|
||||
/*
|
||||
* Other centralised seat functions.
|
||||
|
@ -190,7 +190,7 @@ static void ssh2_userauth_filter_queue(struct ssh2_userauth_state *s)
|
||||
string.len = BANNER_LIMIT - bufchain_size(&s->banner);
|
||||
if (!s->banner_scc_initialised) {
|
||||
s->banner_scc = seat_stripctrl_new(
|
||||
s->ppl.seat, BinarySink_UPCAST(&s->banner_bs), false, 0);
|
||||
s->ppl.seat, BinarySink_UPCAST(&s->banner_bs), SIC_BANNER);
|
||||
s->banner_scc_initialised = true;
|
||||
}
|
||||
if (s->banner_scc)
|
||||
|
@ -351,11 +351,11 @@ static bool gtk_seat_get_window_pixel_size(Seat *seat, int *w, int *h)
|
||||
return true;
|
||||
}
|
||||
|
||||
StripCtrlChars *gtk_seat_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution)
|
||||
StripCtrlChars *gtk_seat_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic)
|
||||
{
|
||||
GtkFrontend *inst = container_of(seat, GtkFrontend, seat);
|
||||
return stripctrl_new_term(bs_out, permit_cr, substitution, inst->term);
|
||||
return stripctrl_new_term(bs_out, false, 0, inst->term);
|
||||
}
|
||||
|
||||
static void gtk_seat_notify_remote_exit(Seat *seat);
|
||||
|
@ -465,10 +465,10 @@ static void console_eventlog(LogPolicy *lp, const char *string)
|
||||
console_logging_error(lp, string);
|
||||
}
|
||||
|
||||
StripCtrlChars *console_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution)
|
||||
StripCtrlChars *console_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic)
|
||||
{
|
||||
return stripctrl_new(bs_out, permit_cr, substitution);
|
||||
return stripctrl_new(bs_out, false, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -388,10 +388,10 @@ static void console_eventlog(LogPolicy *lp, const char *string)
|
||||
console_logging_error(lp, string);
|
||||
}
|
||||
|
||||
StripCtrlChars *console_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution)
|
||||
StripCtrlChars *console_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic)
|
||||
{
|
||||
return stripctrl_new(bs_out, permit_cr, substitution);
|
||||
return stripctrl_new(bs_out, false, 0);
|
||||
}
|
||||
|
||||
static void console_data_untrusted(HANDLE hout, const char *data, size_t len)
|
||||
|
@ -320,10 +320,10 @@ bool win_seat_get_window_pixel_size(Seat *seat, int *x, int *y)
|
||||
return true;
|
||||
}
|
||||
|
||||
StripCtrlChars *win_seat_stripctrl_new(Seat *seat, BinarySink *bs_out,
|
||||
bool permit_cr, wchar_t substitution)
|
||||
StripCtrlChars *win_seat_stripctrl_new(
|
||||
Seat *seat, BinarySink *bs_out, SeatInteractionContext sic)
|
||||
{
|
||||
return stripctrl_new_term(bs_out, permit_cr, substitution, term);
|
||||
return stripctrl_new_term(bs_out, false, 0, term);
|
||||
}
|
||||
|
||||
static size_t win_seat_output(
|
||||
|
Loading…
Reference in New Issue
Block a user