Merge pull request #3012 from thinkyhead/fix_command_injection

Use a serial line buffer to prevent queue corruption
This commit is contained in:
Scott Lahteine
2016-03-19 01:43:54 -07:00
6 changed files with 137 additions and 124 deletions

View File

@ -479,7 +479,7 @@ static void lcd_main_menu() {
*/
void lcd_set_home_offsets() {
// M428 Command
enqueuecommands_P(PSTR("M428"));
enqueue_and_echo_commands_P(PSTR("M428"));
lcd_return_to_status();
}
@ -1530,7 +1530,7 @@ menu_edit_type(unsigned long, long5, ftostr5, 0.01)
lcd_move_y();
}
static void reprapworld_keypad_move_home() {
enqueuecommands_P((PSTR("G28"))); // move all axis home
enqueue_and_echo_commands_P((PSTR("G28"))); // move all axis home
}
#endif // REPRAPWORLD_KEYPAD
@ -1582,18 +1582,13 @@ void lcd_quick_feedback() {
*/
static void menu_action_back(menuFunc_t func) { lcd_goto_menu(func); }
static void menu_action_submenu(menuFunc_t func) { lcd_save_previous_menu(); lcd_goto_menu(func); }
static void menu_action_gcode(const char* pgcode) { enqueuecommands_P(pgcode); }
static void menu_action_gcode(const char* pgcode) { enqueue_and_echo_commands_P(pgcode); }
static void menu_action_function(menuFunc_t func) { (*func)(); }
#if ENABLED(SDSUPPORT)
static void menu_action_sdfile(const char* filename, char* longFilename) {
char cmd[30];
char* c;
sprintf_P(cmd, PSTR("M23 %s"), filename);
for (c = &cmd[4]; *c; c++) *c = tolower(*c);
enqueuecommand(cmd);
enqueuecommands_P(PSTR("M24"));
card.openAndPrintFile(filename);
lcd_return_to_status();
}
@ -2339,7 +2334,7 @@ char* ftostr52(const float& x) {
current_position[Z_AXIS] = MESH_HOME_SEARCH_Z;
line_to_current(Z_AXIS);
mbl.active = 1;
enqueuecommands_P(PSTR("G28"));
enqueue_and_echo_commands_P(PSTR("G28"));
lcd_return_to_status();
}
else {
@ -2383,7 +2378,7 @@ char* ftostr52(const float& x) {
static void lcd_level_bed() {
axis_known_position[X_AXIS] = axis_known_position[Y_AXIS] = axis_known_position[Z_AXIS] = false;
mbl.reset();
enqueuecommands_P(PSTR("G28"));
enqueue_and_echo_commands_P(PSTR("G28"));
lcdDrawUpdate = 2;
lcd_goto_menu(_lcd_level_bed_homing);
}