Fix elf loader range checking
[qemu] / slirp / misc.c
index 9ff3176..0137e75 100644 (file)
@@ -5,7 +5,6 @@
  * terms and conditions of the copyright.
  */
 
-#define WANT_SYS_IOCTL_H
 #include <slirp.h>
 
 u_int curtime, time_fasttimo, last_slowtimo;
@@ -70,7 +69,7 @@ redir_x(inaddr, start_port, display, screen)
  * Get our IP address and put it in our_addr
  */
 void
-getouraddr()
+getouraddr(void)
 {
        char buff[256];
        struct hostent *he = NULL;
@@ -83,47 +82,13 @@ getouraddr()
             our_addr.s_addr = loopback_addr.s_addr;
 }
 
-#if SIZEOF_CHAR_P == 8
-
-struct quehead_32 {
-       u_int32_t qh_link;
-       u_int32_t qh_rlink;
-};
-
-inline void
-insque_32(a, b)
-       void *a;
-       void *b;
-{
-       register struct quehead_32 *element = (struct quehead_32 *) a;
-       register struct quehead_32 *head = (struct quehead_32 *) b;
-       element->qh_link = head->qh_link;
-       head->qh_link = (u_int32_t)element;
-       element->qh_rlink = (u_int32_t)head;
-       ((struct quehead_32 *)(element->qh_link))->qh_rlink
-       = (u_int32_t)element;
-}
-
-inline void
-remque_32(a)
-       void *a;
-{
-       register struct quehead_32 *element = (struct quehead_32 *) a;
-       ((struct quehead_32 *)(element->qh_link))->qh_rlink = element->qh_rlink;
-       ((struct quehead_32 *)(element->qh_rlink))->qh_link = element->qh_link;
-       element->qh_rlink = 0;
-}
-
-#endif /* SIZEOF_CHAR_P == 8 */
-
 struct quehead {
        struct quehead *qh_link;
        struct quehead *qh_rlink;
 };
 
 inline void
-insque(a, b)
-       void *a, *b;
+insque(void *a, void *b)
 {
        register struct quehead *element = (struct quehead *) a;
        register struct quehead *head = (struct quehead *) b;
@@ -135,8 +100,7 @@ insque(a, b)
 }
 
 inline void
-remque(a)
-     void *a;
+remque(void *a)
 {
   register struct quehead *element = (struct quehead *) a;
   ((struct quehead *)(element->qh_link))->qh_rlink = element->qh_rlink;
@@ -149,12 +113,7 @@ remque(a)
 
 
 int
-add_exec(ex_ptr, do_pty, exec, addr, port)
-       struct ex_list **ex_ptr;
-       int do_pty;
-       char *exec;
-       int addr;
-       int port;
+add_exec(struct ex_list **ex_ptr, int do_pty, char *exec, int addr, int port)
 {
        struct ex_list *tmp_ptr;
 
@@ -169,7 +128,7 @@ add_exec(ex_ptr, do_pty, exec, addr, port)
        (*ex_ptr)->ex_fport = port;
        (*ex_ptr)->ex_addr = addr;
        (*ex_ptr)->ex_pty = do_pty;
-       (*ex_ptr)->ex_exec = strdup(exec);
+       (*ex_ptr)->ex_exec = (do_pty == 3) ? exec : strdup(exec);
        (*ex_ptr)->ex_next = tmp_ptr;
        return 0;
 }
@@ -396,7 +355,7 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
                        argv[i++] = strdup(curarg);
                   } while (c);
 
-               argv[i] = 0;
+                argv[i] = NULL;
                execvp(argv[0], (char **)argv);
 
                /* Ooops, failed, let's tell the user why */
@@ -435,9 +394,9 @@ fork_exec(struct socket *so, const char *ex, int do_pty)
                fd_nonblock(so->s);
 
                /* Append the telnet options now */
-               if (so->so_m != 0 && do_pty == 1)  {
+                if (so->so_m != NULL && do_pty == 1)  {
                        sbappend(so, so->so_m);
-                       so->so_m = 0;
+                        so->so_m = NULL;
                }
 
                return 1;
@@ -590,14 +549,14 @@ relay(s)
 #endif
 
 #ifdef CONFIG_QEMU
-extern void term_vprintf(const char *fmt, va_list ap);
+#include "monitor.h"
 
 void lprint(const char *format, ...)
 {
     va_list args;
 
     va_start(args, format);
-    term_vprintf(format, args);
+    monitor_vprintf(cur_mon, format, args);
     va_end(args);
 }
 #else
@@ -797,8 +756,7 @@ sprintf_len(va_alist) va_dcl
 #endif
 
 void
-u_sleep(usec)
-       int usec;
+u_sleep(int usec)
 {
        struct timeval t;
        fd_set fdset;
@@ -816,11 +774,14 @@ u_sleep(usec)
  */
 
 void
-fd_nonblock(fd)
-       int fd;
+fd_nonblock(int fd)
 {
 #ifdef FIONBIO
-       int opt = 1;
+#ifdef _WIN32
+        long opt = 1;
+#else
+        int opt = 1;
+#endif
 
        ioctlsocket(fd, FIONBIO, &opt);
 #else
@@ -833,8 +794,7 @@ fd_nonblock(fd)
 }
 
 void
-fd_block(fd)
-       int fd;
+fd_block(int fd)
 {
 #ifdef FIONBIO
        int opt = 0;