From 982115e516fea287e014233a40a6435d82a66ad3 Mon Sep 17 00:00:00 2001 From: Waldemar Kornewald Date: Wed, 29 Sep 2004 07:35:31 +0000 Subject: [PATCH] Fixed a buffer overflow caused by our R5 select() emulation. Added missing uname() function which is needed for full R5 compatibility. It seems that nearly all apps are working now. I could finally run Vision (BONE and R5), BeShare (quick test only), lynx, Net+, etc. Apps that don't work: Mozilla for BONE, some ssh binary that I downloaded, Be's ftp when not in passive mode. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9098 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kits/network/libnet/compat.c | 20 ++++++++++++++++++++ src/kits/network/libnet/select.c | 7 ++++--- 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/kits/network/libnet/compat.c b/src/kits/network/libnet/compat.c index 5cf90b9cb0..901cfbd57c 100644 --- a/src/kits/network/libnet/compat.c +++ b/src/kits/network/libnet/compat.c @@ -142,3 +142,23 @@ _EXPORT int getpassword(char * pwd, size_t length) } +struct utsname { + char sysname[32]; + char nodename[32]; + char release[32]; + char version[32]; + char machine[32]; +}; +int uname(struct utsname *name); +_EXPORT int uname(struct utsname *name) +{ + if(!name) + return B_ERROR; + + strcpy(name->sysname, "BeOS"); + strcpy(name->nodename, "trantor"); + strcpy(name->release, "5.0"); + strcpy(name->version, "1000009"); + strcpy(name->machine, "BePC"); + return B_OK; +} diff --git a/src/kits/network/libnet/select.c b/src/kits/network/libnet/select.c index 6ae6aec382..f32ea873ab 100644 --- a/src/kits/network/libnet/select.c +++ b/src/kits/network/libnet/select.c @@ -146,16 +146,17 @@ _EXPORT int select(int nbits, struct fd_set * rbits, case B_WOULD_BLOCK: case B_TIMED_OUT: // logicly, 'n' should stay to 0 in this case... n = 0; + // IMPORTANT: memcpy uses the old R5 fd_bits size (sizeof(unsigned) * 8)! if (rbits) { - memcpy(rbits, &rss->rbits, sizeof(*rbits)); + memcpy(rbits, &rss->rbits, sizeof(unsigned) * 8); n += fd_set_count(rbits, nbits); }; if (wbits) { - memcpy(wbits, &rss->wbits, sizeof(*wbits)); + memcpy(wbits, &rss->wbits, sizeof(unsigned) * 8); n += fd_set_count(wbits, nbits); }; if (ebits) { - memcpy(ebits, &rss->ebits, sizeof(*ebits)); + memcpy(ebits, &rss->ebits, sizeof(unsigned) * 8); n += fd_set_count(ebits, nbits); }; break;