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>
# [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:
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.
/* 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)
{
#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(),
#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 {
}
#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 */