Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 56 lines (42 sloc) 1.107 kB
6c16212 @cklein Clean checkout
cklein authored
1 /*
2 * decode_rlogin.c
3 *
4 * Berkeley remote login/shell/exec.
5 *
6 * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7 *
8 * $Id: decode_rlogin.c,v 1.6 2001/03/15 08:33:02 dugsong Exp $
9 */
10
11 #include "config.h"
12
13 #include <sys/types.h>
14
15 #include <stdio.h>
16 #include <string.h>
d0fbb14 @wertarbyte apply debian patch 11_string_header.patch
authored
17 #include <strlcpy.h>
18 #include <strlcat.h>
6c16212 @cklein Clean checkout
cklein authored
19
20 #include "options.h"
21 #include "decode.h"
22
23 int
24 decode_rlogin(u_char *buf, int len, u_char *obuf, int olen)
25 {
26 u_char *p, *q;
27
28 /* Skip first NULL, or rexec stderr port */
29 for (p = buf; p - buf < len && *p == '\0'; p++)
30 ; /* VOID */
31
32 strlcpy(obuf, "[", olen);
33 strlcat(obuf, p, olen); /* Local username */
34 strlcat(obuf, ":", olen);
35 p += strlen(p) + 1;
36
37 strlcat(obuf, p, olen); /* Remote username */
38 strlcat(obuf, "]\n", olen);
39 p += strlen(p) + 1;
40
41 p += strlen(p) + 1; /* Skip term info */
42
43 if ((q = strstr(p, "\xff\xffss")) != NULL) /* Skip window size */
44 p += 12;
45
46 for (p = strtok(p, "\r\n"); p != NULL; p = strtok(NULL, "\r\n")) {
47 strlcat(obuf, p, olen);
48 strlcat(obuf, "\n", olen);
49 }
50 if (!strip_lines(obuf, Opt_lines))
51 return (0);
52
53 return (strlen(obuf));
54 }
55
Something went wrong with that request. Please try again.