mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2026-01-27 12:50:49 +03:00
strncpy is not safe + memory optimization
This commit is contained in:
@@ -611,6 +611,7 @@ static int do_i2s_cmd(int argc, char **argv)
|
|||||||
}
|
}
|
||||||
if(i2s_args.model_name->count>0 && strlen(i2s_args.model_name->sval[0])>0){
|
if(i2s_args.model_name->count>0 && strlen(i2s_args.model_name->sval[0])>0){
|
||||||
strncpy(i2s_dac_pin.model,i2s_args.model_name->sval[0],sizeof(i2s_dac_pin.model));
|
strncpy(i2s_dac_pin.model,i2s_args.model_name->sval[0],sizeof(i2s_dac_pin.model));
|
||||||
|
i2s_dac_pin.model[sizeof(i2s_dac_pin.model) - 1] = '\0';
|
||||||
}
|
}
|
||||||
if(!nerrors ){
|
if(!nerrors ){
|
||||||
fprintf(f,"Storing i2s parameters.\n");
|
fprintf(f,"Storing i2s parameters.\n");
|
||||||
|
|||||||
@@ -117,8 +117,10 @@ static bool wifi_join(const char *ssid, const char *pass, int timeout_ms)
|
|||||||
initialise_wifi();
|
initialise_wifi();
|
||||||
wifi_config_t wifi_config = { 0 };
|
wifi_config_t wifi_config = { 0 };
|
||||||
strncpy((char *) wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid));
|
strncpy((char *) wifi_config.sta.ssid, ssid, sizeof(wifi_config.sta.ssid));
|
||||||
|
wifi_config.sta.ssid[sizeof(wifi_config.sta.ssid) - 1] = '\0';
|
||||||
if (pass) {
|
if (pass) {
|
||||||
strncpy((char *) wifi_config.sta.password, pass, sizeof(wifi_config.sta.password));
|
strncpy((char *) wifi_config.sta.password, pass, sizeof(wifi_config.sta.password));
|
||||||
|
wifi_config.sta.password[sizeof(wifi_config.sta.password) - 1] = '\0';
|
||||||
}
|
}
|
||||||
|
|
||||||
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
|
ESP_ERROR_CHECK( esp_wifi_set_mode(WIFI_MODE_STA) );
|
||||||
|
|||||||
@@ -47,14 +47,14 @@ static EXT_RAM_ATTR struct button_s {
|
|||||||
TimerHandle_t timer;
|
TimerHandle_t timer;
|
||||||
} buttons[MAX_BUTTONS];
|
} buttons[MAX_BUTTONS];
|
||||||
|
|
||||||
static struct {
|
static EXT_RAM_ATTR struct {
|
||||||
int gpio, level;
|
int gpio, level;
|
||||||
struct button_s *button;
|
struct button_s *button;
|
||||||
} polled_gpio[] = { {36, -1, NULL}, {39, -1, NULL}, {-1, -1, NULL} };
|
} polled_gpio[] = { {36, -1, NULL}, {39, -1, NULL}, {-1, -1, NULL} };
|
||||||
|
|
||||||
static TimerHandle_t polled_timer;
|
static TimerHandle_t polled_timer;
|
||||||
|
|
||||||
static struct {
|
static EXT_RAM_ATTR struct {
|
||||||
QueueHandle_t queue;
|
QueueHandle_t queue;
|
||||||
void *client;
|
void *client;
|
||||||
rotary_encoder_info_t info;
|
rotary_encoder_info_t info;
|
||||||
@@ -62,7 +62,7 @@ static struct {
|
|||||||
rotary_handler handler;
|
rotary_handler handler;
|
||||||
} rotary;
|
} rotary;
|
||||||
|
|
||||||
static struct {
|
static EXT_RAM_ATTR struct {
|
||||||
RingbufHandle_t rb;
|
RingbufHandle_t rb;
|
||||||
infrared_handler handler;
|
infrared_handler handler;
|
||||||
} infrared;
|
} infrared;
|
||||||
|
|||||||
@@ -28,7 +28,7 @@
|
|||||||
|
|
||||||
static const char *TAG = "led";
|
static const char *TAG = "led";
|
||||||
|
|
||||||
static struct led_s {
|
static EXT_RAM_ATTR struct led_s {
|
||||||
gpio_num_t gpio;
|
gpio_num_t gpio;
|
||||||
bool on;
|
bool on;
|
||||||
int onstate;
|
int onstate;
|
||||||
@@ -40,7 +40,7 @@ static struct led_s {
|
|||||||
TimerHandle_t timer;
|
TimerHandle_t timer;
|
||||||
} leds[MAX_LED];
|
} leds[MAX_LED];
|
||||||
|
|
||||||
static struct {
|
static EXT_RAM_ATTR struct {
|
||||||
int gpio;
|
int gpio;
|
||||||
int active;
|
int active;
|
||||||
int pwm;
|
int pwm;
|
||||||
|
|||||||
@@ -244,8 +244,7 @@ static void visu_handler(u8_t *data, int len);
|
|||||||
static void dmxt_handler(u8_t *data, int len);
|
static void dmxt_handler(u8_t *data, int len);
|
||||||
static void displayer_task(void* arg);
|
static void displayer_task(void* arg);
|
||||||
|
|
||||||
// PLACEHOLDER
|
void *led_display;
|
||||||
void *led_display = 0x1000;
|
|
||||||
|
|
||||||
/* scrolling undocumented information
|
/* scrolling undocumented information
|
||||||
grfs
|
grfs
|
||||||
@@ -537,7 +536,8 @@ static void show_display_buffer(char *ddram) {
|
|||||||
char *line2;
|
char *line2;
|
||||||
|
|
||||||
memset(line1, 0, LINELEN+1);
|
memset(line1, 0, LINELEN+1);
|
||||||
strncpy(line1, ddram, LINELEN);
|
strncpy(line1, ddram, LINELEN+1);
|
||||||
|
line1[LINELEN] = '\0';
|
||||||
line2 = &(ddram[LINELEN]);
|
line2 = &(ddram[LINELEN]);
|
||||||
line2[LINELEN] = '\0';
|
line2[LINELEN] = '\0';
|
||||||
|
|
||||||
|
|||||||
@@ -292,6 +292,7 @@ void wifi_manager_init_wifi(){
|
|||||||
|
|
||||||
void set_lms_server_details(in_addr_t ip, u16_t hport, u16_t cport){
|
void set_lms_server_details(in_addr_t ip, u16_t hport, u16_t cport){
|
||||||
strncpy(lms_server_ip,inet_ntoa(ip),sizeof(lms_server_ip));
|
strncpy(lms_server_ip,inet_ntoa(ip),sizeof(lms_server_ip));
|
||||||
|
lms_server_ip[sizeof(lms_server_ip)-1]='\0';
|
||||||
ESP_LOGI(TAG,"LMS IP: %s, hport: %d, cport: %d",lms_server_ip, hport, cport);
|
ESP_LOGI(TAG,"LMS IP: %s, hport: %d, cport: %d",lms_server_ip, hport, cport);
|
||||||
lms_server_port = hport;
|
lms_server_port = hport;
|
||||||
lms_server_cport = cport;
|
lms_server_cport = cport;
|
||||||
|
|||||||
Reference in New Issue
Block a user