]> gitweb.ps.run Git - ps-cgit/blobdiff - html.c
html: check return value of write
[ps-cgit] / html.c
diff --git a/html.c b/html.c
index 90cc1c0099198da575119e0b0f38fa3db478f785..d60a41ffd45859e748588f488f2ac8f38f9119ad 100644 (file)
--- a/html.c
+++ b/html.c
@@ -39,7 +39,7 @@ static const char* url_escape_table[256] = {
        "%fe", "%ff"
 };
 
-int htmlfd = STDOUT_FILENO;
+static int htmlfd = STDOUT_FILENO;
 
 char *fmt(const char *format, ...)
 {
@@ -63,12 +63,13 @@ char *fmt(const char *format, ...)
 
 void html_raw(const char *data, size_t size)
 {
-       write(htmlfd, data, size);
+       if (write(htmlfd, data, size) != size)
+               fprintf(stderr, "[html.c] html output truncated.\n");
 }
 
 void html(const char *txt)
 {
-       write(htmlfd, txt, strlen(txt));
+       html_raw(txt, strlen(txt));
 }
 
 void htmlf(const char *format, ...)
@@ -266,7 +267,7 @@ int html_include(const char *filename)
        return 0;
 }
 
-int hextoint(char c)
+static int hextoint(char c)
 {
        if (c >= 'a' && c <= 'f')
                return 10 + c - 'a';
@@ -278,7 +279,7 @@ int hextoint(char c)
                return -1;
 }
 
-char *convert_query_hexchar(char *txt)
+static char *convert_query_hexchar(char *txt)
 {
        int d1, d2, n;
        n = strlen(txt);