xref: /openbsd-src/regress/usr.sbin/syslogd/args-memory-overflow.pl (revision 6954f9bae03bdcbcc160f18219eea2b368c82bbc)
1aa580fcbSbluhm# The client writes message to overflow the memory buffer method.
2aa580fcbSbluhm# The syslogd writes it into a file and through a pipe.
3aa580fcbSbluhm# The syslogd passes it via UDP to the loghost.
4aa580fcbSbluhm# The server receives the message on its UDP socket.
5aa580fcbSbluhm# Syslogc checks the memory logs.
6aa580fcbSbluhm# Check that memory buffer has overflow flag.
7aa580fcbSbluhm
8aa580fcbSbluhmuse strict;
9aa580fcbSbluhmuse warnings;
10aa580fcbSbluhm
11aa580fcbSbluhmour %args = (
12aa580fcbSbluhm    client => {
13aa580fcbSbluhm	func => sub {
14aa580fcbSbluhm	    my $self = shift;
15*6954f9baSbluhm	    write_lines($self, 40, 2000);
16aa580fcbSbluhm	    write_log($self);
17aa580fcbSbluhm	},
18aa580fcbSbluhm    },
19aa580fcbSbluhm    syslogd => {
20aa580fcbSbluhm	memory => 1,
21aa580fcbSbluhm	loggrep => {
22aa580fcbSbluhm	    qr/Accepting control connection/ => 5,
23aa580fcbSbluhm	    qr/ctlcmd 1/ => 1,  # read
24aa580fcbSbluhm	    qr/ctlcmd 2/ => 1,  # read clear
25aa580fcbSbluhm	    qr/ctlcmd 4/ => 3,  # list
26aa580fcbSbluhm	},
27aa580fcbSbluhm    },
28aa580fcbSbluhm    syslogc => [ {
29aa580fcbSbluhm	options => ["-q"],
30aa580fcbSbluhm	loggrep => qr/^memory\* /,
31aa580fcbSbluhm    }, {
32aa580fcbSbluhm	options => ["memory"],
33aa580fcbSbluhm	down => get_downlog(),
34aa580fcbSbluhm	loggrep => {},
35aa580fcbSbluhm    }, {
36aa580fcbSbluhm	options => ["-q"],
37aa580fcbSbluhm	loggrep => qr/^memory\* /,
38aa580fcbSbluhm    }, {
39aa580fcbSbluhm	options => ["-c", "memory"],
40aa580fcbSbluhm	down => get_downlog(),
41aa580fcbSbluhm	loggrep => {},
42aa580fcbSbluhm    }, {
43aa580fcbSbluhm	options => ["-q"],
44aa580fcbSbluhm	loggrep => qr/^memory /,
45aa580fcbSbluhm    } ],
46aa580fcbSbluhm);
47aa580fcbSbluhm
48aa580fcbSbluhm1;
49