Introduction
Introduction Statistics Contact Development Disclaimer Help
Merge pull request #2 from hmage/master - fiche - A pastebin adjusted for gophe…
git clone git://vernunftzentrum.de/fiche.git
Log
Files
Refs
LICENSE
---
commit c23aee0900e15be512d525fc72339bb85f397521
parent cb774abf27c10a8ba300a4e4ae11a5c8c2d174df
Author: solusipse <[email protected]>
Date: Tue, 17 Sep 2013 13:35:55 -0700
Merge pull request #2 from hmage/master
Fix segfaults
Diffstat:
.gitignore | 2 ++
fiche.c | 15 +++++++--------
fiche.h | 5 ++---
3 files changed, 11 insertions(+), 11 deletions(-)
---
diff --git a/.gitignore b/.gitignore
@@ -0,0 +1,2 @@
+# ignore binaries
+/fiche
diff --git a/fiche.c b/fiche.c
@@ -84,8 +84,8 @@ void *thread_connection(void *args)
if (status != -1)
{
- char slug[SLUG_SIZE];
- generate_url(buffer, slug);
+ char slug[SLUG_SIZE+1];
+ generate_url(buffer, slug, SLUG_SIZE+1);
save_log(slug, data.ip_address, data.hostname);
char response[strlen(slug) + strlen(DOMAIN) + 2];
snprintf(response, sizeof response, "%s%s\n", DOMAIN, slug);
@@ -256,10 +256,10 @@ void bind_to_port(int listen_socket, struct sockaddr_in s…
error("ERROR while starting listening");
}
-void generate_url(char *buffer, char *slug)
+void generate_url(char *buffer, char *slug, size_t slug_length)
{
int i;
- memset(slug, '\0', sizeof(slug));
+ memset(slug, '\0', slug_length);
for (i = 0; i <= SLUG_SIZE - 1; i++)
{
@@ -278,7 +278,7 @@ void generate_url(char *buffer, char *slug)
int create_directory(char *slug)
{
- char *directory = malloc(strlen(BASEDIR) + strlen(slug));
+ char *directory = malloc(strlen(BASEDIR) + strlen(slug) + 1);
strcpy(directory, BASEDIR);
strcat(directory, slug);
@@ -295,7 +295,7 @@ int create_directory(char *slug)
void save_to_file(char *slug, char *buffer)
{
- char *directory = malloc(strlen(BASEDIR) + strlen(slug) + strlen("/index.t…
+ char *directory = malloc(strlen(BASEDIR) + strlen(slug) + strlen("/index.t…
strcpy(directory, BASEDIR);
strcat(directory, slug);
strcat(directory, "/index.txt");
@@ -391,4 +391,4 @@ void parse_parameters(int argc, char **argv)
printf(" [-l log file] [-b banlist] [-w wh…
exit(1);
}
-}
-\ No newline at end of file
+}
diff --git a/fiche.h b/fiche.h
@@ -67,7 +67,7 @@ void error(char *error_code){perror(error_code); exit(1);}
void nerror(char *error_code){perror(error_code);}
void display_date();
void perform_connection(int listen_socket);
-void generate_url(char *buffer, char *slug);
+void generate_url(char *buffer, char *slug, size_t slug_length);
void save_to_file(char *buffer, char *slug);
void startup_message();
void set_basedir();
@@ -97,4 +97,4 @@ struct client_data
char *hostname;
};
-#endif
-\ No newline at end of file
+#endif
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.