antispoof.c 887 B

1234567891011121314151617181920212223242526272829
  1. #include "putty.h"
  2. #include "misc.h"
  3. void seat_antispoof_msg(InteractionReadySeat iseat, const char *msg)
  4. {
  5. strbuf *sb = strbuf_new();
  6. seat_set_trust_status(iseat.seat, true);
  7. if (seat_can_set_trust_status(iseat.seat)) {
  8. /*
  9. * If the seat can directly indicate that this message is
  10. * generated by the client, then we can just use the message
  11. * unmodified as an unspoofable header.
  12. */
  13. put_dataz(sb, msg);
  14. } else if (*msg) {
  15. /*
  16. * Otherwise, add enough padding around it that the server
  17. * wouldn't be able to mimic it within our line-length
  18. * constraint.
  19. */
  20. put_fmt(sb, "-- %s ", msg);
  21. while (sb->len < 78)
  22. put_byte(sb, '-');
  23. }
  24. put_datapl(sb, PTRLEN_LITERAL("\r\n"));
  25. seat_banner_pl(iseat, ptrlen_from_strbuf(sb));
  26. strbuf_free(sb);
  27. }