We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bb695a7 commit e18f268Copy full SHA for e18f268
output.c
@@ -5,6 +5,8 @@
5
#include <string.h>
6
#include <stdarg.h>
7
8
+#define STRING_MAX 4096
9
+
10
output_t output = { .level = verbose };
11
12
#define PREFIX(FD, L) write(FD, prefixes[L], prefixes_len[L]);
@@ -28,15 +30,15 @@ void sprint(char *str, output_level_t l)
28
30
if(output.level < l) return;
29
31
32
PREFIX(STDOUT_FILENO, l);
- write(STDOUT_FILENO, str, strlen(str));
33
+ write(STDOUT_FILENO, str, strnlen(str, STRING_MAX));
34
}
35
36
void eprint(char *str, output_level_t l)
37
{
38
39
40
PREFIX(STDERR_FILENO, l);
- write(STDERR_FILENO, str, strlen(str));
41
+ write(STDERR_FILENO, str, strnlen(str, STRING_MAX));
42
43
44
void sprintln(char *str, output_level_t l)
0 commit comments