File: decode_x11.c

package info (click to toggle)
dsniff 2.4b1+debian-29
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 2,020 kB
  • sloc: ansic: 10,803; sh: 152; makefile: 126
file content (45 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (4)
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
/*
 * decode_x11.c
 *
 * X11.
 *
 * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
 *
 * $Id: decode_x11.c,v 1.4 2001/03/15 08:33:03 dugsong Exp $
 */

#include "config.h"

#include <sys/types.h>

#include <stdio.h>
#include <string.h>
#include <strlcat.h>
#include <strlcpy.h>

#include "decode.h"

int
decode_x11(u_char *buf, int len, u_char *obuf, int olen)
{
	char *p, *q;
	int i;
	
	p = buf + 12;
	
	if (strncmp(p, "MIT-MAGIC-COOKIE-1", 18) != 0 || len < 36)
		return (0);
	
	strlcpy(obuf, "MIT-MAGIC-COOKIE-1 ", olen);
	
	p += 20;
	len -= 20;
	q = obuf + 19;
	
	for (i = 0; i < 16 && i < len; i++)
		sprintf(q + (i * 2), "%.2x", (u_char)p[i]);
	strlcat(obuf, "\n", olen);
	
	return (strlen(obuf));
}