Introduction
Introduction Statistics Contact Development Disclaimer Help
Merge pull request #22 from Hypsurus/master - fiche - A pastebin adjusted for g…
git clone git://vernunftzentrum.de/fiche.git
Log
Files
Refs
LICENSE
---
commit f6ecdab9c52621ee3f42095a05365aeb9155f1ec
parent 4c3f5908e36d6037c26400fc6bbfe7c6fc343b4f
Author: solusipse <[email protected]>
Date: Tue, 13 Oct 2015 19:19:07 +0200
Merge pull request #22 from Hypsurus/master
Fix segfault, and error().
Diffstat:
fiche.c | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/fiche.c b/fiche.c
@@ -40,11 +40,11 @@ int main(int argc, char **argv)
if (getuid() == 0)
{
if (UID == -1)
- error("ERROR: user not set");
+ error("user not set");
if (setgid(GID) != 0)
- error("ERROR: Unable to drop group privileges");
+ error("Unable to drop group privileges");
if (setuid(UID) != 0)
- error("ERROR: Unable to drop user privileges");
+ error("Unable to drop user privileges");
}
if (BASEDIR == NULL)
@@ -67,7 +67,7 @@ int main(int argc, char **argv)
pid = fork();
if (pid == -1)
- error("ERROR: Failed to fork");
+ error("Failed to fork");
if (pid == 0)
while (1) perform_connection(listen_socket);
}
@@ -142,16 +142,16 @@ void perform_connection(int listen_socket)
timeout.tv_usec = 0;
if (setsockopt (connection_socket, SOL_SOCKET, SO_RCVTIMEO, (char *)&timeo…
- error("ERROR while setting setsockopt timeout");
+ error("while setting setsockopt timeout");
if (setsockopt (connection_socket, SOL_SOCKET, SO_SNDTIMEO, (char *)&timeo…
- error("ERROR while setting setsockopt timeout");
+ error("while setting setsockopt timeout");
struct thread_arguments arguments;
arguments.connection_socket = connection_socket;
arguments.client_address = client_address;
if (pthread_create(&thread_id, NULL, &thread_connection, &arguments) != 0)
- error("ERROR on thread creation");
+ error("on thread creation");
else
pthread_detach(thread_id);
}
@@ -244,7 +244,11 @@ char *check_whitelist(char *ip_address)
void load_list(char *file_path, int type)
{
- FILE *fp = fopen(file_path, "r");
+ FILE *fp;
+
+ if (( fp = fopen(file_path, "r")) == NULL )
+ error("cannot load list");
+
fseek(fp, 0, SEEK_END);
long fsize = ftell(fp);
fseek(fp, 0, SEEK_SET);
@@ -268,7 +272,7 @@ int create_socket()
int lsocket = socket(AF_INET, SOCK_STREAM, 0);
if (lsocket < 0)
- error("ERROR: Couldn't open socket");
+ error("Couldn't open socket");
return lsocket;
}
@@ -285,9 +289,9 @@ struct sockaddr_in set_address(struct sockaddr_in server_ad…
void bind_to_port(int listen_socket, struct sockaddr_in server_address)
{
if (bind(listen_socket, (struct sockaddr *) &server_address, sizeof(server…
- error("ERROR while binding to port");
+ error("while binding to port");
if (listen(listen_socket, QUEUE_SIZE) < 0)
- error("ERROR while starting listening");
+ error("while starting listening");
}
void generate_url(char *buffer, char *slug, size_t slug_length, struct client_…
@@ -391,7 +395,7 @@ void startup_message()
void error(char *buffer)
{
- printf("%s\n", buffer);
+ printf("Error: %s\n", buffer);
exit(1);
}
You are viewing proxied material from vernunftzentrum.de. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.