diff --git a/server.c b/server.c index e638ec62ba7fb567b40d962deebcdfe8d241bcaa..f3571494c75483945e7e6771c00cc1b78ad4bac8 100644 --- a/server.c +++ b/server.c @@ -378,19 +378,16 @@ bool show_modified_page(int sockfd, const char* htmldir, char* added, bool show_start_page(int sockfd, char* username) { int username_length = strlen(username); char* added_prefix = "<p>"; - int added_prefix_length = strlen(added_prefix); char* added_suffix = "</p>\n\n"; - int added_suffix_length = sizeof(added_suffix); // the length needs to include the html tags for the username int added_length = username_length + 9; char added[added_length]; // create added string - strncpy(added, added_prefix, added_prefix_length); - strncpy(added + added_prefix_length, username, username_length); - strncpy(added + added_prefix_length + username_length, added_suffix, - added_suffix_length); + strcat(added, added_prefix); + strcat(added, username); + strcat(added, added_suffix); return show_modified_page(sockfd, START_PAGE, added, 212); } @@ -407,7 +404,7 @@ bool show_accepted_page(int sockfd) { int added_suffix_length = sizeof(added_suffix); for (int i = 0; i < list_len; i++) { - + } return show_modified_page(sockfd, ACCEPTED_PAGE, added, 212);