Merge pull request #23 from cgie/warnings - fiche - A pastebin adjusted for gopher use
 (HTM) git clone git://vernunftzentrum.de/fiche.git
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit f76eea893134922fd8166f775a08252bea9b0fcb
 (DIR) parent f6ecdab9c52621ee3f42095a05365aeb9155f1ec
 (HTM) Author: solusipse <solus1ps3@gmail.com>
       Date:   Sat, 31 Oct 2015 12:47:19 +0100
       
       Merge pull request #23 from cgie/warnings
       
       added checks on the return values of read/write
       Diffstat:
         fiche.c                             |      15 ++++++++++-----
       
       1 file changed, 10 insertions(+), 5 deletions(-)
       ---
 (DIR) diff --git a/fiche.c b/fiche.c
       @@ -92,7 +92,8 @@ void *thread_connection(void *args)
            {
                display_info(data, NULL, "Rejected connection from unknown user.");
                save_log(NULL, data.ip_address, data.hostname);
       -        write(connection_socket, "You are not whitelisted!\n", 26);
       +        if (write(connection_socket, "You are not whitelisted!\n", 26) < 0)
       +          printf("Error writing on stream socket\n");
                close(connection_socket);
                pthread_exit(NULL);
            }
       @@ -101,7 +102,8 @@ void *thread_connection(void *args)
            {
                display_info(data, NULL, "Rejected connection from banned user.");
                save_log(NULL, data.ip_address, data.hostname);
       -        write(connection_socket, "You are banned!\n", 17);
       +        if (write(connection_socket, "You are banned!\n", 17) < 0)
       +          printf("Error writing on stream socket\n");
                close(connection_socket);
                pthread_exit(NULL);
            }
       @@ -116,13 +118,15 @@ void *thread_connection(void *args)
                save_log(slug, data.ip_address, data.hostname);
                char response[strlen(slug) + strlen(DOMAIN) + 2];
                snprintf(response, sizeof response, "%s%s\n", DOMAIN, slug);
       -        write(connection_socket, response, strlen(response));
       +        if (write(connection_socket, response, strlen(response)) < 0)
       +          printf("Error writing on stream socket\n");
            }
            else
            {
                display_info(data, NULL, "Invalid connection.");
                save_log(NULL, data.ip_address, data.hostname);
       -        write(connection_socket, "Use netcat.\n", 12);
       +        if (write(connection_socket, "Use netcat.\n", 12) < 0)
       +          printf("Error writing on stream socket\n");
            }
        
            close(connection_socket);
       @@ -254,7 +258,8 @@ void load_list(char *file_path, int type)
            fseek(fp, 0, SEEK_SET);
        
            char *buffer = malloc(fsize + 1);
       -    fread(buffer, fsize, 1, fp);
       +    if (fread(buffer, fsize, 1, fp) != fsize)
       +      error("reading list failed");
            fclose(fp);
        
            buffer[fsize] = 0;