fix-build-warnings

This commit is contained in:
wt committed 2025-04-15 11:29:44 +07:00
1 parent 05dc4c299f
commit 903a4268aa
7 files changed
+17 -25

No files matched your search

+3 -5
View File
@@ -12,7 +12,7 @@
#define PORT 8081
#define BUFFER_SIZE 512
#define MAX_PATH 128
#define MAX_PATH 512
#define ROOT_DIR "."
typedef struct handle_request_data {
@@ -69,7 +69,6 @@ static void list_files(SSL *ssl, char *directory) {
while ((entry = readdir(dir)) && pos < sizeof(buf) - 100) {
if (!strcmp(entry->d_name, ".")) continue;
if (!strcmp(entry->d_name, "..") && !strcmp(directory, ROOT_DIR)) continue;
struct stat st;
char path[MAX_PATH];
snprintf(path, sizeof(path), "%s/%s", directory, entry->d_name);
pos += snprintf(buf + pos, sizeof(buf) - pos,
@@ -86,7 +85,7 @@ void *handle_request(void *param) {
int client_sock = param_data->socket;
SSL *ssl = param_data->ssl;
char *req = param_data->req;
char method[8], path[MAX_PATH], proto[8];
char method[8], path[MAX_PATH-2], proto[8];
if (sscanf(req, "%7s %127s %7s", method, path, proto) != 3) {
send_response(ssl, "400 Bad Request", "text/plain", "Bad Request", 11);
SSL_shutdown(ssl);
@@ -129,12 +128,11 @@ void *handle_request(void *param) {
char file_path[MAX_PATH];
snprintf(file_path, sizeof(file_path), "%s/%s", ROOT_DIR, path[0] == '/' ? path + 1 : path);
if (file_path[0] == "." && file_path[1] == "/") {
if (file_path[0] == '.' && file_path[1] == '/') {
for (int i = 2; i < MAX_PATH -1; i++) {
file_path[i-2] = file_path[i];
}
}
https://localhost:8081/home/tola/Pictures/home/tola/Pictures/wallpaper/3d-tech.jpg
struct stat st;
if (stat(file_path, &st) < 0 || S_ISDIR(st.st_mode)) {
if (S_ISDIR(st.st_mode)) {