What I had in mind was using the function as the basis for a
complete program; ie,

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char **argv) {
  FILE  *fp;
  long  x = 0;

  printf("at start, x=%lu\n", x);
  if ((fp = fopen("/dev/urandom", "r")) != NULL)
    {
      (void) fread(&x, sizeof(x), 1, fp);
      fclose(fp);
    }
  printf("after reading from /dev/urandom, x=%lu\n", x);
  x += time(NULL) + getpid() + getppid();
  printf("after adding in the time and pids, x=%lu\n", x);
  srand48(x);
  printf("we've seeded the rng.\n");
}


Compile and run it. The actual numbers printed aren't important, just whether it yields a SIGSEGV.


George,

I've compiled your source and ran it. This is the output:

at start, x=0
after reading from /dev/urandom, x=28244400
after adding in the time and pids, x=1141048885
we've seeded the rng.

With truss the output is:
917648: 1392879: execve("./a.out", 0x2FF22BD8, 0x2FF22BE0) argc: 1
917648: 1392879: argv: ./a.out
917648: 1392879: envp: _=/usr/bin/truss LANG=en_US
917648: 1392879: WSM_WS_CMD=/usr/HTTPServer/bin/apachectl restart LOGIN=root
917648: 1392879: PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:/usr/bin/X11:/sbin:/usr/java14_64/jre/bin:/usr/java14_64/bin:/usr/local/bin:/usr/local/sbin:/usr/dt/bin:/usr/krb5/bin:/usr/vac/bin:/opt/freeware/bin:/var/ifor:/usr/opt/ifor/ls/conf:/usr/opt/ifor/ls/os/aix/bin:/usr/HTTPServer/apache2/bin
917648: 1392879: LC__FASTMSG=true LOGNAME=root MAIL=/usr/spool/mail/root
917648: 1392879: LOCPATH=/usr/lib/nls/loc WSM_DOC_DIR=/usr/HTTPServer/htdocs USER=root
917648: 1392879: AUTHSTATE=compat SHELL=/usr/bin/ksh ODMDIR=/etc/objrepos HOME=/
917648: 1392879: TERM=xterm MAILMSG=[YOU HAVE NEW MAIL]
917648: 1392879: PWD=/export/compile_src/nessus.sav/gosse TZ=NFT-1DFT,M3.5.0,M10.5.0
917648: 1392879: ENV=.kshrc WSM_CGI_DIR=/usr/HTTPServer/cgi-bin A__z=! LOGNAME
917648: 1392879: NLSPATH=/usr/lib/nls/msg/%L/%N:/usr/lib/nls/msg/%L/%N.cat
917648: 1392879: __loadx(0x0A040000, 0xD03EEAA4, 0x00000003, 0x10000000, 0x200002F3) = 0x00000000
917648: 1392879: kioctl(1, 22528, 0x00000000, 0x00000000) = 0
917648: 1392879: kwrite(1, " a t s t a r t , x =".., 14) = 14
917648: 1392879: open("/dev/urandom", O_RDONLY) = 3
917648: 1392879: kioctl(3, 22528, 0x00000000, 0x00000000) = 0
917648: 1392879: sbrk(0x00000000) = 0x20000F34
917648: 1392879: sbrk(0x0000000C) = 0x20000F34
917648: 1392879: __libc_sbrk(0x00000000) = 0x20000F40
917648: 1392879: kioctl(3, 22528, 0x00000000, 0x00000000) = 0
917648: 1392879: kfcntl(1, F_GETFL, 0x00000020) = 67110914
917648: 1392879: kread(3, " � � � � S 9 ; �9B 8 . �".., 4096) = 4096
917648: 1392879: close(3) = 0
917648: 1392879: kwrite(1, " a f t e r r e a d i n".., 46) = 46
917648: 1392879: _getpid() = 917648
917648: 1392879: _getppid() = 901254
917648: 1392879: kwrite(1, " a f t e r a d d i n g".., 47) = 47
917648: 1392879: kwrite(1, " w e ' v e s e e d e d".., 22) = 22
917648: 1392879: kfcntl(1, F_GETFL, 0x20000D04) = 67110914
917648: 1392879: kfcntl(2, F_GETFL, 0xF02D4790) = 67110914
917648: 1392879: _exit(-1)


Seems ok, doesn't it? No SIGSEGV ....

_________________________________________________________________
Gebruik MSN Webmessenger op je werk en op school http://webmessenger.msn.com/


_______________________________________________
Nessus mailing list
[email protected]
http://mail.nessus.org/mailman/listinfo/nessus

Reply via email to