2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# ignore binaries
|
||||||
|
/fiche
|
||||||
14
fiche.c
14
fiche.c
@@ -84,8 +84,8 @@ void *thread_connection(void *args)
|
|||||||
|
|
||||||
if (status != -1)
|
if (status != -1)
|
||||||
{
|
{
|
||||||
char slug[SLUG_SIZE];
|
char slug[SLUG_SIZE+1];
|
||||||
generate_url(buffer, slug);
|
generate_url(buffer, slug, SLUG_SIZE+1);
|
||||||
save_log(slug, data.ip_address, data.hostname);
|
save_log(slug, data.ip_address, data.hostname);
|
||||||
char response[strlen(slug) + strlen(DOMAIN) + 2];
|
char response[strlen(slug) + strlen(DOMAIN) + 2];
|
||||||
snprintf(response, sizeof response, "%s%s\n", DOMAIN, slug);
|
snprintf(response, sizeof response, "%s%s\n", DOMAIN, slug);
|
||||||
@@ -256,10 +256,10 @@ void bind_to_port(int listen_socket, struct sockaddr_in server_address)
|
|||||||
error("ERROR while starting listening");
|
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;
|
int i;
|
||||||
memset(slug, '\0', sizeof(slug));
|
memset(slug, '\0', slug_length);
|
||||||
|
|
||||||
for (i = 0; i <= SLUG_SIZE - 1; i++)
|
for (i = 0; i <= SLUG_SIZE - 1; i++)
|
||||||
{
|
{
|
||||||
@@ -278,7 +278,7 @@ void generate_url(char *buffer, char *slug)
|
|||||||
|
|
||||||
int create_directory(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);
|
strcpy(directory, BASEDIR);
|
||||||
strcat(directory, slug);
|
strcat(directory, slug);
|
||||||
@@ -295,7 +295,7 @@ int create_directory(char *slug)
|
|||||||
|
|
||||||
void save_to_file(char *slug, char *buffer)
|
void save_to_file(char *slug, char *buffer)
|
||||||
{
|
{
|
||||||
char *directory = malloc(strlen(BASEDIR) + strlen(slug) + strlen("/index.txt"));
|
char *directory = malloc(strlen(BASEDIR) + strlen(slug) + strlen("/index.txt") + 1);
|
||||||
strcpy(directory, BASEDIR);
|
strcpy(directory, BASEDIR);
|
||||||
strcat(directory, slug);
|
strcat(directory, slug);
|
||||||
strcat(directory, "/index.txt");
|
strcat(directory, "/index.txt");
|
||||||
@@ -391,4 +391,4 @@ void parse_parameters(int argc, char **argv)
|
|||||||
printf(" [-l log file] [-b banlist] [-w whitelist]\n");
|
printf(" [-l log file] [-b banlist] [-w whitelist]\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
4
fiche.h
4
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 nerror(char *error_code){perror(error_code);}
|
||||||
void display_date();
|
void display_date();
|
||||||
void perform_connection(int listen_socket);
|
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 save_to_file(char *buffer, char *slug);
|
||||||
void startup_message();
|
void startup_message();
|
||||||
void set_basedir();
|
void set_basedir();
|
||||||
@@ -97,4 +97,4 @@ struct client_data
|
|||||||
char *hostname;
|
char *hostname;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user