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_cvs.c
Go to the documentation of this file.
1 /*
2  * decode_cvs.c
3  *
4  * Concurrent Versions System.
5  *
6  * Copyright (c) 2000 Dug Song <dugsong@monkey.org>
7  *
8  * $Id: decode_cvs.c,v 1.6 2001/03/15 08:32:59 dugsong Exp $
9  */
10 
11 #include "config.h"
12 
13 #include <sys/types.h>
14 #include <stdio.h>
15 #include <string.h>
16 
17 #include "buf.h"
18 #include "decode.h"
19 
20 /* stolen from CVS scramble.c */
21 static u_char cvs_shifts[] = {
22  0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
23  16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31,
24  114,120, 53, 79, 96,109, 72,108, 70, 64, 76, 67,116, 74, 68, 87,
25  111, 52, 75,119, 49, 34, 82, 81, 95, 65,112, 86,118,110,122,105,
26  41, 57, 83, 43, 46,102, 40, 89, 38,103, 45, 50, 42,123, 91, 35,
27  125, 55, 54, 66,124,126, 59, 47, 92, 71,115, 78, 88,107,106, 56,
28  36,121,117,104,101,100, 69, 73, 99, 63, 94, 93, 39, 37, 61, 48,
29  58,113, 32, 90, 44, 98, 60, 51, 33, 97, 62, 77, 84, 80, 85,223,
30  225,216,187,166,229,189,222,188,141,249,148,200,184,136,248,190,
31  199,170,181,204,138,232,218,183,255,234,220,247,213,203,226,193,
32  174,172,228,252,217,201,131,230,197,211,145,238,161,179,160,212,
33  207,221,254,173,202,146,224,151,140,196,205,130,135,133,143,246,
34  192,159,244,239,185,168,215,144,139,165,180,157,147,186,214,176,
35  227,231,219,169,175,156,206,198,129,164,150,210,154,177,134,127,
36  182,128,158,208,162,132,167,209,149,241,153,251,237,236,171,195,
37  243,233,253,240,194,250,191,155,142,137,245,235,163,242,178,152
38 };
39 
40 int
41 decode_cvs(u_char *buf, int len, u_char *obuf, int olen)
42 {
43  struct buf *line, inbuf, outbuf;
44  u_char *p;
45  int i, n;
46 
47  buf_init(&inbuf, buf, len);
48  buf_init(&outbuf, obuf, olen);
49 
50  if (buf_cmp(&inbuf, "BEGIN ", 6) != 0)
51  return (0);
52 
53  for (n = 0; n < 5 && (i = buf_index(&inbuf, "\n", 1)) != -1; n++) {
54  line = buf_tok(&inbuf, NULL, i + 1);
55  line->base[line->end - 1] = '\0';
56 
57  p = buf_ptr(line);
58  buf_putf(&outbuf, "%s", p);
59 
60  if (n == 3) {
61  if (p[0] != 'A')
62  return (0);
63 
64  for (i = 1; i < sizeof(cvs_shifts) - 1 && p[i]; i++)
65  p[i] = cvs_shifts[p[i]];
66 
67  buf_putf(&outbuf, " [%s]", p + 1);
68  }
69  buf_put(&outbuf, "\n", 1);
70  }
71  buf_end(&outbuf);
72 
73  return (buf_len(&outbuf));
74 }
75 
decode_cvs
int decode_cvs(u_char *buf, int len, u_char *obuf, int olen)
Definition: decode_cvs.c:41
buf_putf
int buf_putf(buf_t buf, const char *fmt,...)
Definition: buf.c:106
buf_init
void buf_init(buf_t buf, u_char *data, int len)
Definition: buf.c:24
buf_end
void buf_end(buf_t buf)
Definition: buf.c:121
buf_put
int buf_put(buf_t buf, void *src, int len)
Definition: buf.c:93
decode.h
buf.h
buf
Definition: buf.h:14
buf_tok
buf_t buf_tok(buf_t buf, void *sep, int len)
Definition: buf.c:167
buf_ptr
#define buf_ptr(b)
Definition: buf.h:31
line
Definition: sshow.c:62
buf_cmp
int buf_cmp(buf_t buf, void *ptr, int len)
Definition: buf.c:158
config.h
obuf
static char obuf[4096]
Definition: trigger.c:43
buf_len
#define buf_len(b)
Definition: buf.h:34
cvs_shifts
static u_char cvs_shifts[]
Definition: decode_cvs.c:21
buf_index
int buf_index(buf_t buf, void *ptr, int len)
Definition: buf.c:128