dsniff  2.4b2
About: A collection of tools for network auditing
  Fossies Dox: dsniff-2.4b2.tar.gz  ("inofficial" and yet experimental doxygen-generated source code documentation)  

decode_x11.c
Go to the documentation of this file.
1 /*
2  * decode_x11.c
3  *
4  * X11.
5  *
6  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7  *
8  * $Id: decode_x11.c,v 1.4 2001/03/15 08:33:03 dugsong Exp $
9  */
10 
11 #include "config.h"
12 
13 #include <sys/types.h>
14 
15 #include <stdio.h>
16 #include <string.h>
17 
18 #include "decode.h"
19 
20 int
21 decode_x11(u_char *buf, int len, u_char *obuf, int olen)
22 {
23  char *p, *q;
24  int i;
25 
26  p = buf + 12;
27 
28  if (strncmp(p, "MIT-MAGIC-COOKIE-1", 18) != 0 || len < 36)
29  return (0);
30 
31  strlcpy(obuf, "MIT-MAGIC-COOKIE-1 ", olen);
32 
33  p += 20;
34  len -= 20;
35  q = obuf + 19;
36 
37  for (i = 0; i < 16 && i < len; i++)
38  sprintf(q + (i * 2), "%.2x", (u_char)p[i]);
39  strlcat(obuf, "\n", olen);
40 
41  return (strlen(obuf));
42 }
43 
strlcpy
size_t strlcpy(char *dst, const char *src, size_t siz)
Definition: strlcpy.c:43
decode_x11
int decode_x11(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_x11.c:21
decode.h
buf
Definition: buf.h:14
config.h
obuf
static char obuf[4096]
Definition: trigger.c:43
strlcat
size_t strlcat(char *dst, const char *src, size_t siz)
Definition: strlcat.c:44