Ver código fonte

Fixes an PSTR overflow with print_xyz()

João Brázio 9 anos atrás
pai
commit
ffbb31b235
1 arquivos alterados com 12 adições e 6 exclusões
  1. 12
    6
      Marlin/Marlin_main.cpp

+ 12
- 6
Marlin/Marlin_main.cpp Ver arquivo

@@ -580,17 +580,23 @@ static void report_current_position();
580 580
     SERIAL_ECHOPAIR(", ", y);
581 581
     SERIAL_ECHOPAIR(", ", z);
582 582
     SERIAL_ECHOPGM(")");
583
-    serialprintPGM(suffix);
583
+
584
+    if (suffix) serialprintPGM(suffix);
585
+    else SERIAL_EOL;
584 586
   }
585
-  void print_xyz(const char* prefix,const char* suffix, const float xyz[]) {
587
+
588
+  void print_xyz(const char* prefix, const char* suffix, const float xyz[]) {
586 589
     print_xyz(prefix, suffix, xyz[X_AXIS], xyz[Y_AXIS], xyz[Z_AXIS]);
587 590
   }
591
+
588 592
   #if ENABLED(AUTO_BED_LEVELING_FEATURE)
589
-    void print_xyz(const char* prefix,const char* suffix, const vector_3 &xyz) {
593
+    void print_xyz(const char* prefix, const char* suffix, const vector_3 &xyz) {
590 594
       print_xyz(prefix, suffix, xyz.x, xyz.y, xyz.z);
591 595
     }
592 596
   #endif
593
-  #define DEBUG_POS(SUFFIX,VAR) do{ print_xyz(PSTR(STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); }while(0)
597
+
598
+  #define DEBUG_POS(SUFFIX,VAR) do { \
599
+    print_xyz(PSTR(STRINGIFY(VAR) "="), PSTR(" : " SUFFIX "\n"), VAR); } while(0)
594 600
 #endif
595 601
 
596 602
 #if ENABLED(DELTA) || ENABLED(SCARA)
@@ -1657,7 +1663,7 @@ static void do_blocking_move_to(float x, float y, float z, float feed_rate = 0.0
1657 1663
   float old_feedrate = feedrate;
1658 1664
 
1659 1665
   #if ENABLED(DEBUG_LEVELING_FEATURE)
1660
-    if (DEBUGGING(LEVELING)) print_xyz(PSTR("do_blocking_move_to"), "", x, y, z);
1666
+    if (DEBUGGING(LEVELING)) print_xyz(PSTR("do_blocking_move_to"), NULL, x, y, z);
1661 1667
   #endif
1662 1668
 
1663 1669
   #if ENABLED(DELTA)
@@ -6626,7 +6632,7 @@ inline void gcode_T(uint8_t tmp_extruder) {
6626 6632
             delayed_move_time = 0;
6627 6633
             break;
6628 6634
         }
6629
- 
6635
+
6630 6636
         #if ENABLED(DEBUG_LEVELING_FEATURE)
6631 6637
           if (DEBUGGING(LEVELING)) {
6632 6638
             SERIAL_ECHOPAIR("Active extruder parked: ", active_extruder_parked ? "yes" : "no");

Carregando…
Cancelar
Salvar