… | |
… | |
32 | #include <time.h> |
32 | #include <time.h> |
33 | #include <signal.h> |
33 | #include <signal.h> |
34 | |
34 | |
35 | #include <global.h> |
35 | #include <global.h> |
36 | #include <material.h> |
36 | #include <material.h> |
|
|
37 | #include <object.h> |
37 | |
38 | |
38 | #include <sys/time.h> |
39 | #include <sys/time.h> |
39 | #include <sys/resource.h> |
40 | #include <sys/resource.h> |
40 | |
41 | |
41 | #include <glib.h> |
42 | #include <glib.h> |
… | |
… | |
445 | } |
446 | } |
446 | else |
447 | else |
447 | strcpy (input, tmp); |
448 | strcpy (input, tmp); |
448 | |
449 | |
449 | return; |
450 | return; |
|
|
451 | } |
|
|
452 | |
|
|
453 | /******************************************************************************/ |
|
|
454 | |
|
|
455 | /* Checks a player-provided string which will become the msg property of |
|
|
456 | * an object for dangerous input. |
|
|
457 | */ |
|
|
458 | bool |
|
|
459 | msg_is_safe (const char *msg) |
|
|
460 | { |
|
|
461 | bool safe = true; |
|
|
462 | |
|
|
463 | /* Trying to cheat by getting data into the object */ |
|
|
464 | if (!strncmp (msg, "endmsg", strlen ("endmsg")) || strstr (msg, "\nendmsg")) |
|
|
465 | safe = false; |
|
|
466 | |
|
|
467 | /* Trying to make the object talk, and potentially access arbitrary code */ |
|
|
468 | if (object::msg_has_dialogue (msg)) |
|
|
469 | safe = false; |
|
|
470 | |
|
|
471 | return safe; |
450 | } |
472 | } |
451 | |
473 | |
452 | ///////////////////////////////////////////////////////////////////////////// |
474 | ///////////////////////////////////////////////////////////////////////////// |
453 | |
475 | |
454 | void |
476 | void |