Return to BSD News archive
Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!newsroom.utas.edu.au!munnari.oz.au!ihnp4.ucsd.edu!agate!nickkral
From: nickkral@parker.EECS.Berkeley.EDU (Nick Kralevich)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: porting Linux apps to BSD !
Date: 23 Aug 1995 08:37:33 GMT
Organization: Electrical Engineering Computer Science Department, University of California at Berkeley
Lines: 55
Message-ID: <41epcd$bn4@agate.berkeley.edu>
References: <aak2.808728796@Ra.MsState.Edu> <41dkk4$fbn@news.rwth-aachen.de>
NNTP-Posting-Host: parker.eecs.berkeley.edu
In article <41dkk4$fbn@news.rwth-aachen.de>,
Guido Muesch <odiug@gom.informatik.rwth-aachen.de> wrote:
>Under Linux this works, because they remapped the zero
>page, so they have a 0 at position 0.
Ummm, no.
I've tested all of the following programs on a Linux 1.2.13 a.out
system, and they all generate seg faults. (for the sake of space, all of
these code fragments should be preceded by "#include <stdio.h>" and
"#include <string.h>").
----- Begin -----
main() {
char * foo = NULL;
char * bar = NULL;
printf("%c\n", foo[0]);
}
----- End -----
----- Begin -----
main() {
char * foo = NULL;
char * bar = NULL;
strcpy(foo, bar);
}
----- End -----
----- Begin -----
main() {
char * foo = NULL;
char * bar = (char *) malloc(100 * sizeof(char));
if (bar == NULL) exit(1);
strcpy (foo, bar);
}
----- End -----
----- Begin -----
main() {
char * foo = NULL;
char * bar = (char *) malloc(100 * sizeof(char));
if (bar == NULL) exit(1);
strcpy (bar, foo);
}
----- End -----
>I personally prefer getting a SIGSEGV so that I can clean up my code.
>8-)
Agreed.
Take care,
-- Nick Kralevich
nickkral@cory.eecs.berkeley.edu