增加网络配置界面
This commit is contained in:
@@ -6,6 +6,8 @@
|
||||
#include <stdbool.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "lftpd.h"
|
||||
#include "private/lftpd_status.h"
|
||||
#include "private/lftpd_inet.h"
|
||||
@@ -222,14 +224,14 @@ static int cmd_cwd(lftpd_client_t *client, const char *arg)
|
||||
int is_dir;
|
||||
if (lftpd_io_stat(path, &size, &is_dir) != 0 || !is_dir) {
|
||||
send_simple_response(client->socket, 550, STATUS_550);
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
strncpy(client->directory, path, sizeof(client->directory) - 1);
|
||||
client->directory[sizeof(client->directory) - 1] = '\0';
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
|
||||
send_simple_response(client->socket, 250, STATUS_250);
|
||||
return 0;
|
||||
@@ -248,18 +250,18 @@ static int cmd_dele(lftpd_client_t *client, const char *arg)
|
||||
int is_dir;
|
||||
if (lftpd_io_stat(path, &size, &is_dir) != 0) {
|
||||
send_simple_response(client->socket, 550, STATUS_550);
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (is_dir) {
|
||||
send_simple_response(client->socket, 550, STATUS_550);
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
return -1;
|
||||
}
|
||||
|
||||
lftpd_io_unlink(path);
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
send_simple_response(client->socket, 250, STATUS_250);
|
||||
return 0;
|
||||
}
|
||||
@@ -459,7 +461,7 @@ static int cmd_retr(lftpd_client_t *client, const char *arg)
|
||||
lftpd_log_error("DOWNLOAD '%s' FAILED", path);
|
||||
send_simple_response(client->socket, 450, STATUS_450);
|
||||
}
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -481,7 +483,7 @@ static int cmd_size(lftpd_client_t *client, const char *arg)
|
||||
send_simple_response(client->socket, 550, STATUS_550);
|
||||
}
|
||||
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -518,7 +520,7 @@ static int cmd_stor(lftpd_client_t *client, const char *arg)
|
||||
lftpd_log_error("UPLOAD '%s' FAILED", path);
|
||||
send_simple_response(client->socket, 450, STATUS_450);
|
||||
}
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
|
||||
#include "ff.h"
|
||||
#include "private/lftpd_io.h"
|
||||
|
||||
@@ -41,19 +43,19 @@ char *lftpd_io_canonicalize_path(const char *base, const char *name)
|
||||
|
||||
char *path;
|
||||
if (name[0] == '/') {
|
||||
path = (char *)malloc(strlen(name) + 1);
|
||||
path = (char *)pvPortMalloc(strlen(name) + 1);
|
||||
if (path == NULL) return NULL;
|
||||
strcpy(path, name);
|
||||
} else {
|
||||
size_t len = strlen(base) + 1 + strlen(name) + 1;
|
||||
path = (char *)malloc(len);
|
||||
path = (char *)pvPortMalloc(len);
|
||||
if (path == NULL) return NULL;
|
||||
snprintf(path, len, "%s/%s", base, name);
|
||||
}
|
||||
|
||||
char *abs_path = (char *)malloc(strlen(path) + 2);
|
||||
char *abs_path = (char *)pvPortMalloc(strlen(path) + 2);
|
||||
if (abs_path == NULL) {
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
return NULL;
|
||||
}
|
||||
abs_path[0] = '\0';
|
||||
@@ -83,7 +85,7 @@ char *lftpd_io_canonicalize_path(const char *base, const char *name)
|
||||
|
||||
*p = saved;
|
||||
}
|
||||
free(path);
|
||||
vPortFree(path);
|
||||
|
||||
if (strlen(abs_path) == 0) {
|
||||
strcpy(abs_path, "/");
|
||||
@@ -186,13 +188,13 @@ int lftpd_io_unlink(const char *path)
|
||||
|
||||
void *lftpd_io_opendir(const char *path)
|
||||
{
|
||||
DIR *dp = (DIR *)malloc(sizeof(DIR));
|
||||
DIR *dp = (DIR *)pvPortMalloc(sizeof(DIR));
|
||||
if (dp == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
const char *fpath = to_fatfs_path(path);
|
||||
if (f_opendir(dp, fpath) != FR_OK) {
|
||||
free(dp);
|
||||
vPortFree(dp);
|
||||
return NULL;
|
||||
}
|
||||
return (void *)dp;
|
||||
@@ -230,6 +232,6 @@ void lftpd_io_closedir(void *dp)
|
||||
{
|
||||
if (dp != NULL) {
|
||||
f_closedir((DIR *)dp);
|
||||
free(dp);
|
||||
vPortFree(dp);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user