diff options
author | Ilya Zakharevich <ilya@math.ohio-state.edu> | 1997-01-09 17:02:16 -0500 |
---|---|---|
committer | Chip Salzenberg <chip@atlantic.net> | 1997-01-16 07:24:00 +1200 |
commit | 9a3e71f668bd84b1cf53dd3ea10f588d59ecfebb (patch) | |
tree | aa78709bd0b27fa6a085f32730bbcb8868f6baf7 | |
parent | a9bc755754f0db5e848e65dfd2e63a96af50ffd4 (diff) | |
download | perl-9a3e71f668bd84b1cf53dd3ea10f588d59ecfebb.tar.gz |
Perl 5.003_20: OS/2 patches
Chip Salzenberg writes:
>
> It's all become so routine:
>
> file: $CPAN/authors/id/CHIPS/perl5.003_20.pat.gz
Below are latest os/2-related patches. **** Note the first chunk ****
It shows that under OS/2 4-argument select was writing over memory
(256 bites = 32 bytes) over what is typically 1-char malloc area.
Since an exception of the general rule is needed on linux and OS/2,
can we trust this rule at all? There may be zillions of obscure
little-endian systems where select sets all the bytes it cares about
instead of just the passed number.
If one wants a Configure test for this, here is the skeleton:
#include <stdlib.h>
#include <sys/select.h>
char buffer[81] = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
char buffer1[81] = "01234567890123456789012345678901234567890123456789012345678901234567890123456789";
int
main (int argc, char* argv[], char* envp[])
{
int i = 80;
buffer[0] = 2; /* stdout */
select(8, NULL, (fd_set *)buffer, NULL, NULL);
while (i > 0 && buffer1[i] == buffer[i]) i--;
printf("%i bytes overwritten.\n", i+1);
exit(0);
}
Enjoy,
Ilya
This patch does the following:
a) substitutes BSD (s)random instead of broken EMX's one;
b) removes rsignal from os2/os2.c since it it exported now;
c) defines `register' to none if better debugging is deemed necessary.
d) fixes broken pp_sselect.
p5p-msgid: <199701101102.GAA19051@monk.mps.ohio-state.edu>
-rw-r--r-- | hints/os2.sh | 4 | ||||
-rw-r--r-- | os2/Changes | 5 | ||||
-rw-r--r-- | os2/os2.c | 16 | ||||
-rw-r--r-- | os2/os2ish.h | 7 | ||||
-rw-r--r-- | pp_sys.c | 2 |
5 files changed, 16 insertions, 18 deletions
diff --git a/hints/os2.sh b/hints/os2.sh index 59087e3888..9bce2a594c 100644 --- a/hints/os2.sh +++ b/hints/os2.sh @@ -129,7 +129,9 @@ fi # [Maybe we should just remove c from $libswanted ?] -libs='-lsocket -lm' +# Test would pick up wrong rand, so we hardwire the value for random() +libs='-lsocket -lm -lbsd' +randbits=31 archobjs="os2$obj_ext dl_os2$obj_ext" # Run files without extension with sh: diff --git a/os2/Changes b/os2/Changes index 83af2d8893..902783295f 100644 --- a/os2/Changes +++ b/os2/Changes @@ -122,3 +122,8 @@ after 5.003_08: after 5.003_11: Functions emx_{malloc,realloc,calloc,free} are exported from DLL. get_sysinfo() bugs corrected (flags were not used and wrongly defined). + +after 5.003_20: + _isterm is substituted instead of isatty, s?random instead of srand. + `register' disabled if -DDEBUGGING and not AOUT build: stupid SD386. + 3-argument select() was stomping over memory. @@ -158,22 +158,6 @@ getpriority(int which /* ignored */, int pid) /* spawn */ typedef void (*Sigfunc) _((int)); -static -Sigfunc rsignal(signo,handler) -int signo; -Sigfunc handler; -{ - struct sigaction act,oact; - - act.sa_handler = handler; - sigemptyset(&act.sa_mask); - act.sa_flags = 0; - if (sigaction(signo, &act, &oact) < 0) - return(SIG_ERR); - else - return(oact.sa_handler); -} - static int result(int flag, int pid) { diff --git a/os2/os2ish.h b/os2/os2ish.h index b2e1f66c78..44aee84152 100644 --- a/os2/os2ish.h +++ b/os2/os2ish.h @@ -99,6 +99,8 @@ char *my_tmpnam (char *); #define tmpfile my_tmpfile #define tmpnam my_tmpnam #define isatty _isterm +#define rand random +#define srand srandom /* * fwrite1() should be a routine with the same calling sequence as fwrite(), @@ -155,6 +157,11 @@ void *emx_realloc (void *, size_t); #endif +/* With SD386 it is impossible to debug register variables. */ +#if !defined(PERL_IS_AOUT) && defined(DEBUGGING) && !defined(register) +# define register +#endif + /* Our private OS/2 specific data. */ typedef struct OS2_Perl_data { @@ -675,7 +675,7 @@ PP(pp_sselect) } #if BYTEORDER == 0x1234 || BYTEORDER == 0x12345678 -#ifdef __linux__ +#if defined(__linux__) || defined(OS2) growsize = sizeof(fd_set); #else growsize = maxlen; /* little endians can use vecs directly */ |