File: antispoof.c

package info (click to toggle)
putty 0.83-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 13,216 kB
  • sloc: ansic: 148,476; python: 8,466; perl: 1,830; makefile: 128; sh: 117
file content (28 lines) | stat: -rw-r--r-- 887 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include "putty.h"
#include "misc.h"

void seat_antispoof_msg(InteractionReadySeat iseat, const char *msg)
{
    strbuf *sb = strbuf_new();
    seat_set_trust_status(iseat.seat, true);
    if (seat_can_set_trust_status(iseat.seat)) {
        /*
         * If the seat can directly indicate that this message is
         * generated by the client, then we can just use the message
         * unmodified as an unspoofable header.
         */
        put_dataz(sb, msg);
    } else if (*msg) {
        /*
         * Otherwise, add enough padding around it that the server
         * wouldn't be able to mimic it within our line-length
         * constraint.
         */
        put_fmt(sb, "-- %s ", msg);
        while (sb->len < 78)
            put_byte(sb, '-');
    }
    put_datapl(sb, PTRLEN_LITERAL("\r\n"));
    seat_banner_pl(iseat, ptrlen_from_strbuf(sb));
    strbuf_free(sb);
}