Potential buffer overwrite in pem_write_buffer() fixed

Length indication when given a too small buffer was off.
Added regression test in test_suite_pem to detect this.
diff --git a/tests/suites/main_test.function b/tests/suites/main_test.function
index 1c50809..95a924f 100644
--- a/tests/suites/main_test.function
+++ b/tests/suites/main_test.function
@@ -1,6 +1,14 @@
 #include <stdio.h>
 #include <string.h>
 
+#if defined(POLARSSL_PLATFORM_C)
+#include "polarssl/platform.h"
+#else
+#define polarssl_printf     printf
+#define polarssl_malloc     malloc
+#define polarssl_free       free
+#endif
+
 static int test_errors = 0;
 
 SUITE_PRE_DEP