Here is a simple program.
#include <stdio.h>
#include <errno.h>
main(){
int err;
err=read(0,NULL,6);
printf("%d %d\n",err,errno);
}
I think that it should be an error : Null pointer assignment, like in windows.
But in practise it is not so.
Mandrake Linux kernel 2.4.21-0.13mdk
I am a programmer too and i am very interested to solve this problem. Please,
send me fragment of sourse code of kernel with this bug.
Thanks.
Sorry for my English
On Mon, 2005-03-14 at 17:48 +0300, Evgeniy wrote:
> Here is a simple program.
>
> #include <stdio.h>
> #include <errno.h>
> main(){
> int err;
> err=read(0,NULL,6);
> printf("%d %d\n",err,errno);
> }
>
> I think that it should be an error : Null pointer assignment, like in windows.
> But in practise it is not so.
> Mandrake Linux kernel 2.4.21-0.13mdk
> I am a programmer too and i am very interested to solve this problem. Please,
> send me fragment of sourse code of kernel with this bug.
well what is the value of errno ?
-EFAULT by chance ?
On Mon, 2005-03-14 at 15:51 +0100, Arjan van de Ven wrote:
> On Mon, 2005-03-14 at 17:48 +0300, Evgeniy wrote:
> > Here is a simple program.
> >
> > #include <stdio.h>
> > #include <errno.h>
> > main(){
> > int err;
> > err=read(0,NULL,6);
> > printf("%d %d\n",err,errno);
> > }
> >
> > I think that it should be an error : Null pointer assignment, like in windows.
> > But in practise it is not so.
> > Mandrake Linux kernel 2.4.21-0.13mdk
> > I am a programmer too and i am very interested to solve this problem. Please,
> > send me fragment of sourse code of kernel with this bug.
>
> well what is the value of errno ?
> -EFAULT by chance ?
note that you need to include <unistd.h> for the proper read() prototype
btw
On Monday 14 March 2005 15:48, Evgeniy wrote:
> #include <stdio.h>
> #include <errno.h>
> main(){
> int err;
> err=read(0,NULL,6);
> printf("%d %d\n",err,errno);
> }
On my box (2.6.11), that does exactly what it is supposed to do -- "-1 14"
14 == EFAULT == "Bad Address", which is what NULL is...
Btw, printf("%d %d %s\n", err, errno, strerror(errno)); gives you a more
readable error, that would immediately show you did get the right error.
I ran the little test program on my 2.4.26 Knoppix system, and got the
following two results:
strace a.out < /dev/tty
...
read(0, NULL, 6) = 1
...
strace a.out < /dev/zero
...
read(0, 0, 6) = -1 EFAULT (Bad address)
...
The first case looks broken.
Pat
---
On Mon, 14 Mar 2005 17:48:05 +0300
Evgeniy <[email protected]> bubbled:
> Here is a simple program.
>
> #include <stdio.h>
> #include <errno.h>
> main(){
> int err;
> err=read(0,NULL,6);
> printf("%d %d\n",err,errno);
> }
Results:
# ./a < /dev/zero
read(0, 0, 6) = -1 EFAULT (Bad address)
-1 14 Bad address
So everything is fine...
Regards,
Martin
--
MyExcuse:
I'd love to help you -- it's just that the Boss won't let me near the
computer.
Martin Zwickel <[email protected]>
Research & Development
TechnoTrend AG <http://www.technotrend.de>
On Mon, 14 Mar 2005, Evgeniy wrote:
> Here is a simple program.
>
> #include <stdio.h>
> #include <errno.h>
> main(){
> int err;
> err=read(0,NULL,6);
> printf("%d %d\n",err,errno);
> }
>
> I think that it should be an error : Null pointer assignment, like in windows.
> But in practise it is not so.
It is an error. It will wait <forever> until you enter the [Enter]
key (it's reading from STDIN_FILENO). Then it will return -1 which
means there was an error, the error code in errno is 14 (EFAULT)
or "bad address".
You can configure user-mode code to "seg-fault" upon receiving
such an error. It can print a nasty message and leave a worthless
core file in your directory.
Cheers,
Dick Johnson
Penguin : Linux version 2.6.11 on an i686 machine (5537.79 BogoMips).
Notice : All mail here is now cached for review by Dictator Bush.
98.36% of all statistics are fiction.