aboutsummaryrefslogtreecommitdiffstats
path: root/src/tests/klaar/read-bad-buf.c
blob: 1e41562a34262641cf97bd70cec499ef8a244442 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
/* Passes an semingly valid pointer to the read system call.
   The pointer will however span invalid pages.
   The process must be terminated with -1 exit code.
   (klaar@ida)
*/

#include <syscall.h>
#include "tests/lib.h"
#include "tests/main.h"

char global; /* allocated with process image */

void
test_main (void) 
{
  int handle;
  char local; /* allocated on process stack */
  
  CHECK ((handle = open ("sample.txt")) > 1, "open \"sample.txt\"");

  /* buffer will start and end at valid addresses ... */
  read (handle, (char *)&global, &local - &global + 1);
  fail ("should not have survived read()");
}