Date: Tue, 2 Mar 1999 16:26:33 +0100 (MET) From: Emmanuel DELOGET <pixel@DotCom.FR> To: hackers@FreeBSD.ORG (FreeBSD Hackers Mail List) Subject: bug in sysctl_sysctl_name Message-ID: <199903021526.PAA21720@excalibur.oceanis.net>
next in thread | raw e-mail | index | archive | help
Hi, hackers [sorry to disturb you] ! Experiencing with sysctls on different FreeBSD (mostly 2.2.8 and 3.1), it appears that I found an interesting bug in the sysctl code. This is the program that shows this bug : The normal invocation for this test program is prg num1 num2 .... numN. It displays the value of the { num1, ... , numN } OID. Ex : ./sysctl_test 1 1 will print the string : FreeBSD Using this proggy with args 0 1 1 1 will gives kern.ostype But... (there's allways a 'but') a) ./sysctl_test 0 1 5 1 --> panic on 3.1-RELEASE (trap 12, supervisor read, page not present) b) ./sysctl_test 0 1 5 0 --> reboot (without even panicing) on my 2.2.8 The fact is that is't not very good to force a reboot when a syscall just failed :) looking at the code in 2.2.8 for the called function sysctl_sysctl_name, I can't figure what's happening. /**** file sysctl_test.c ****************** cut here */ #include <stdlib.h> #include <stdio.h> #include <sys/types.h> #include <sys/sysctl.h> void main(int ac,char **av) { int oidnum[128]; int nlen,result; char buffer[32768]; int buflen = 16384; /* so I'm sure... */ char c; if (ac < 2) { printf("usage : %s %s\n", av[0], "oidnum1 oidnum2 ... oidnumN"); exit(-1); } for (nlen=1;nlen<ac;nlen++) { oidnum[nlen-1] = atoi(av[nlen]); } result = sysctl(oidnum,nlen-1,buffer,&buflen,NULL,0); if (result < 0) { perror("sysctl"); exit(-1); } if (buflen <= 4) { printf("%d\n",(int)(*buffer)); return; } for (nlen=0;nlen<buflen;nlen++) { c = buffer[nlen]; if (c) { if (c == (char)0x0a) printf("\n"); else { if (c < 32) { printf("[%#.2x]",c); } else { printf("%c",c); } } } } printf("\n"); } /************************************* end of file */ -- ____________________________________________________________________ Emmanuel DELOGET [pixel] pixel@{dotcom.fr,epita.fr} ---- DotCom SA -------------------------------------------------------------------- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199903021526.PAA21720>