@@ -189,7 +189,7 @@ int set_fixed_default_time(void)
189189 struct tm timeinfo = {
190190 .tm_year = YEAR - 1900 , /* years since 1900 */
191191 .tm_mon = MONTH - 1 , /* Month, where 0 = Jan */
192- .tm_mday = DAY - 1 , /* Numeric decimal day of the month */
192+ .tm_mday = DAY , /* Numeric decimal day of the month */
193193 .tm_hour = 13 ,
194194 .tm_min = 1 ,
195195 .tm_sec = 5
@@ -276,7 +276,7 @@ int set_time_from_string(const char* time_buffer)
276276 char offset [28 ]; /* large arrays, just in case there's still bad data */
277277 char day_str [28 ];
278278 char month_str [28 ];
279- const char * format = "%3s %3s %d %d:%d:%d %d %s " ;
279+ const char * format = "%3s %3s %d %d:%d:%d %d %27s " ;
280280 struct tm this_timeinfo ;
281281 struct timeval now ;
282282 time_t interim_time ;
@@ -304,18 +304,23 @@ int set_time_from_string(const char* time_buffer)
304304 "Jul" , "Aug" , "Sep" , "Oct" , "Nov" , "Dec"
305305 };
306306
307- for (int i = 0 ; i < 12 ; i ++ ) {
307+ int i ;
308+ for (i = 0 ; i < 12 ; i ++ ) {
308309 if (strcmp (month_str , months [i ]) == 0 ) {
309310 this_timeinfo .tm_mon = i ;
310311 break ;
311312 }
312313 }
314+ if (i == 12 ) {
315+ return ESP_FAIL ;
316+ }
313317
314318 this_timeinfo .tm_mday = day ;
315319 this_timeinfo .tm_hour = hour ;
316320 this_timeinfo .tm_min = minute ;
317321 this_timeinfo .tm_sec = second ;
318322 this_timeinfo .tm_year = year - 1900 ; /* Years since 1900 */
323+ this_timeinfo .tm_isdst = -1 ;
319324
320325 interim_time = mktime (& this_timeinfo );
321326 now = (struct timeval ){ .tv_sec = interim_time };
@@ -397,11 +402,11 @@ int set_time(void)
397402 }
398403 ESP_LOGI (TAG , "sntp_setservername:" );
399404 for (i = 0 ; i < CONFIG_LWIP_SNTP_MAX_SERVERS ; i ++ ) {
400- const char * thisServer = ntpServerList [i ];
401- if (strncmp (thisServer , "\x00" , 1 ) == 0 ) {
402- /* just in case we run out of NTP servers */
403- break ;
405+ const char * thisServer ;
406+ if (i >= NTP_SERVER_COUNT ) {
407+ break ;
404408 }
409+ thisServer = ntpServerList [i ];
405410 ESP_LOGI (TAG , "%s" , thisServer );
406411 sntp_setservername (i , thisServer );
407412 ret = ESP_OK ;
0 commit comments