Author Topic: FluffOS 2.18 Patches  (Read 1454 times)

Offline Andrew

  • Acquaintance
  • *
  • Posts: 12
    • View Profile
FluffOS 2.18 Patches
« on: October 05, 2013, 05:19:22 AM »
The following diff has fixes for:
* Some crashers
* Mudlib Error Handler stopped getting called (too_deep_error never got reset to 0)
* IPv6 support in portbind

Code: [Select]
diff -rwu fluffos-2.18/interpret.c fluffos-2.18-nan/interpret.c
--- fluffos-2.18/interpret.c    2009-10-19 20:02:22.000000000 +0100
+++ fluffos-2.18-nan/interpret.c        2013-09-17 16:54:27.000000000 +0100
@@ -3810,11 +3814,11 @@
     catch_value = const1;

     /* if it's too deep or max eval, we can't let them catch it */
-    if (max_eval_error) {
+    if (0 && max_eval_error) {
       pop_context(&econ);
       error("Can't catch eval cost too big error.\n");
     }
-    if (0 && too_deep_error) {//can't we??
+    if (too_deep_error) {
       pop_context(&econ);
       error("Can't catch too deep recursion error.\n");
     }
@@ -4188,6 +4192,7 @@
     if (entry->progp) {
       free_prog(&entry->progp);
       entry->progp = 0;
+      entry->funp = 0;
     } else {
       if (entry->funp){
         free_string((char *)entry->funp);
diff -rwu fluffos-2.18/simulate.c fluffos-2.18-nan/simulate.c
--- fluffos-2.18/simulate.c     2009-10-19 20:02:23.000000000 +0100
+++ fluffos-2.18-nan/simulate.c 2013-09-18 16:39:07.000000000 +0100
@@ -409,6 +409,7 @@
         error("Illegal path name '/%s'.\n", real_name);
     }
 
+    if (!inherit_file) {
         /* maybe move this section into compile_file? */
         if (comp_flag) {
             debug_message(" compiling /%s ...", real_name);
@@ -426,7 +427,7 @@
         update_compile_av(total_lines);
         total_lines = 0;
         close(f);
-
+    }
 
     /* Sorry, can't handle objects without programs yet. */
     if (inherit_file == 0 && (num_parse_error > 0 || prog == 0)) {
@@ -1706,19 +1707,20 @@
             num_error--;
             num_mudlib_error = 0;
         } else {
-           if(max_eval_error)
-               outoftime = 0;
-
             if (!too_deep_error) {
                 num_mudlib_error++;
+                outoftime = 0;
                 mudlib_error_handler(err, 1);
+                if (max_eval_error) {
+                    outoftime = 1;
+                }
                 num_mudlib_error--;
             }
         }
 #endif
 #endif
-        if(max_eval_error)
-           outoftime = 1;
+
+        max_eval_error = 0;
         free_svalue(&catch_value, "caught error");
         catch_value.type = T_STRING;
         catch_value.subtype = STRING_MALLOC;
diff -rwu fluffos-2.18/portbind.c fluffos-2.18-nan/portbind.c
--- fluffos-2.18/portbind.c     2009-10-19 20:02:23.000000000 +0100
+++ fluffos-2.18-nan/portbind.c 2009-10-24 10:39:45.000000000 +0100
@@ -5,6 +5,17 @@
 
 #define HANDLE_ERROR(routine, call) if ((call) == -1) { perror(#routine); exit(
-1); }
 
+int valid_ipaddr(const char * ipaddr)
+{
+#ifdef IPV6
+    struct sockaddr_in6 sin;
+
+    return (inet_pton(AF_INET6, ipaddr, &sin.sin6_addr) == 1);
+#else
+    return (inet_addr(ipaddr) != IPADDR_ANY);
+#endif
+}
+
 int main(int argc, char **argv) {
 #ifndef WIN32
     int port = -1;
@@ -15,7 +26,13 @@
     
     int fd;
     int optval = 1;
+#ifdef IPV6
+    int sockdomain = PF_INET6;
+    struct sockaddr_in6 sin;
+#else
+    int sockdomain = PF_INET;
     struct sockaddr_in sin;
+#endif
     
     /*Args are passed down to the driver, but we process the following options:
      *
@@ -59,7 +76,8 @@
            argc -= 2;
            argv += 2;
        } else if (strcmp(argv[1], "-i") == 0) {
-           if (argc == 2 || inet_addr(argv[2]) == INADDR_NONE) {
+           if (argc == 2 ||
+                !valid_ipaddr(argv[2]) ) {
                fprintf(stderr, "%s: -i must be followed by a valid dotted decimal ip address.\n", argv[0]);
                exit(-1);
            }
@@ -75,7 +93,7 @@
     }
 
     /* create the socket */
-    HANDLE_ERROR(socket, fd = socket(AF_INET, SOCK_STREAM, 0));
+    HANDLE_ERROR(socket, fd = socket(sockdomain, SOCK_STREAM, 0));
 
     /* move to fd #6 */
     HANDLE_ERROR(dup2, dup2(fd, 6));
@@ -87,9 +105,21 @@
     HANDLE_ERROR(setsockopt, setsockopt(6, SOL_SOCKET, SO_REUSEADDR, (char *)&optval, sizeof(optval)) == -1);
 
     /* setup our address */
+#ifdef IPV6
+    sin.sin6_family = AF_INET6;
+    if(ipaddress)
+        inet_pton(AF_INET6, ipaddress, &(sin.sin6_addr));
+    else
+        sin.sin6_addr = in6addr_any;
+    sin.sin6_port = htons((u_short) port);
+#else
     sin.sin_family = AF_INET;
-    sin.sin_addr.s_addr = (ipaddress ? inet_addr(ipaddress) : INADDR_ANY);
-    sin.sin_port = htons((unsigned short)port);
+    if (MUD_IP[0])
+        sin.sin_addr.s_addr = inet_addr(MUD_IP);
+    else
+        sin.sin_addr.s_addr = INADDR_ANY;
+    sin.sin_port = htons((u_short) port);
+#endif
 
     /* bind to our address */
     HANDLE_ERROR(bind, bind(6, (struct sockaddr *)&sin, sizeof(sin)));
diff -rwu fluffos-2.18/compiler.c fluffos-2.18-nan/compiler.c
--- fluffos-2.18/compiler.c     2009-10-19 20:02:22.000000000 +0100
+++ fluffos-2.18-nan/compiler.c 2011-02-17 11:20:16.000000000 +0000
@@ -665,9 +665,18 @@
             ovlwarn_t *ow;
             compiler_temp_t *func_entry = FUNCTION_TEMP(oldindex);
             program_t *prog2 = INHERIT(func_entry->offset)->prog;
-            program_t *defprog2;
+            program_t *defprog2 = func_entry->prog;
+
+            if (!defprog2)
+            {
+                function_t * f = ((function_t *) mem_block[A_FUNCTIONS].block +
+                                  func_entry->u.index);
+                p = strput(buf, end, "Undefined function ");
+                p = strput(p, end, f->funcname);
+                yyerror(buf);
+                return ;
+            }
 
-            defprog2 = func_entry->prog;
             p = strput(buf, end, definition->funcname);
             p = strput(p, end, "() inherited from both /");
             p = strput(p, end, defprog->filename);