mirror of https://github.com/vitalif/GPX
Buffer overflow detection
This fixes the bug discovered by Enginwiz, the remaining line input that overflows the input buffer is now ignored.master
parent
f3dfa55641
commit
171030f758
2
Makefile
2
Makefile
|
@ -4,7 +4,7 @@ CC_FLAGS = -w
|
||||||
L_FLAGS = -lm
|
L_FLAGS = -lm
|
||||||
|
|
||||||
# File names
|
# File names
|
||||||
VERSION = 1.2
|
VERSION = 1.3
|
||||||
PLATFORM=osx
|
PLATFORM=osx
|
||||||
ARCHIVE = gpx-$(PLATFORM)-$(VERSION)
|
ARCHIVE = gpx-$(PLATFORM)-$(VERSION)
|
||||||
PREFIX = /usr/local
|
PREFIX = /usr/local
|
||||||
|
|
16
gpx.c
16
gpx.c
|
@ -2231,6 +2231,7 @@ int main(int argc, char * argv[])
|
||||||
char *config = NULL;
|
char *config = NULL;
|
||||||
double filament_diameter = 0;
|
double filament_diameter = 0;
|
||||||
char *buildname = "GPX " GPX_VERSION;
|
char *buildname = "GPX " GPX_VERSION;
|
||||||
|
int overflow = 0;
|
||||||
|
|
||||||
initialize_globals();
|
initialize_globals();
|
||||||
|
|
||||||
|
@ -2460,6 +2461,17 @@ int main(int argc, char * argv[])
|
||||||
// and both the input and output files are open, so its time to parse the
|
// and both the input and output files are open, so its time to parse the
|
||||||
// gcode input and convert it to x3g output
|
// gcode input and convert it to x3g output
|
||||||
while(fgets(buffer, BUFFER_MAX, in) != NULL) {
|
while(fgets(buffer, BUFFER_MAX, in) != NULL) {
|
||||||
|
// detect input buffer overflow and ignore overflow input
|
||||||
|
if(overflow) {
|
||||||
|
if(strlen(buffer) != BUFFER_MAX - 1) {
|
||||||
|
overflow = 0;
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if(strlen(buffer) == BUFFER_MAX - 1) {
|
||||||
|
overflow = 1;
|
||||||
|
fprintf(stderr, "(line %u) Buffer overflow: input exceeds %u character limit, remaining characters in line will be ignored" EOL, lineNumber, BUFFER_MAX);
|
||||||
|
}
|
||||||
// reset flag state
|
// reset flag state
|
||||||
command.flag = 0;
|
command.flag = 0;
|
||||||
char *digits;
|
char *digits;
|
||||||
|
@ -2643,7 +2655,7 @@ int main(int argc, char * argv[])
|
||||||
// revert to tool selection to current extruder
|
// revert to tool selection to current extruder
|
||||||
selectedExtruder = currentExtruder;
|
selectedExtruder = currentExtruder;
|
||||||
|
|
||||||
// change the extruder selection (in virtual tool carosel)
|
// change the extruder selection (in the virtual tool carosel)
|
||||||
if(command.flag & T_IS_SET && !dittoPrinting) {
|
if(command.flag & T_IS_SET && !dittoPrinting) {
|
||||||
unsigned tool_id = (unsigned)command.t;
|
unsigned tool_id = (unsigned)command.t;
|
||||||
if(tool_id < machine.extruder_count) {
|
if(tool_id < machine.extruder_count) {
|
||||||
|
@ -3470,12 +3482,14 @@ int main(int argc, char * argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
// X,Y,Z,A,B,E,F
|
||||||
if(command.flag & (AXES_BIT_MASK | F_IS_SET)) {
|
if(command.flag & (AXES_BIT_MASK | F_IS_SET)) {
|
||||||
do_pause_at_zpos = calculate_target_position();
|
do_pause_at_zpos = calculate_target_position();
|
||||||
queue_ext_point(currentFeedrate);
|
queue_ext_point(currentFeedrate);
|
||||||
update_target_position();
|
update_target_position();
|
||||||
command_emitted++;
|
command_emitted++;
|
||||||
}
|
}
|
||||||
|
// T?
|
||||||
else if(!dittoPrinting && selectedExtruder != currentExtruder) {
|
else if(!dittoPrinting && selectedExtruder != currentExtruder) {
|
||||||
int timeout = command.flag & P_IS_SET ? (int)command.p : 0xFFFF;
|
int timeout = command.flag & P_IS_SET ? (int)command.p : 0xFFFF;
|
||||||
do_tool_change(timeout);
|
do_tool_change(timeout);
|
||||||
|
|
2
gpx.h
2
gpx.h
|
@ -29,7 +29,7 @@
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
#define GPX_VERSION "1.2"
|
#define GPX_VERSION "1.3"
|
||||||
|
|
||||||
/* Nonzero to 'simulate' RPM using 5D, zero to disable */
|
/* Nonzero to 'simulate' RPM using 5D, zero to disable */
|
||||||
|
|
||||||
|
|
2
gpx.ini
2
gpx.ini
|
@ -24,11 +24,11 @@
|
||||||
; r1 = Replicator 1 - single extruder
|
; r1 = Replicator 1 - single extruder
|
||||||
; r1d = Replicator 1 - dual extruder
|
; r1d = Replicator 1 - dual extruder
|
||||||
; r2 = Replicator 2 (default config)
|
; r2 = Replicator 2 (default config)
|
||||||
|
; r2h = Replicator 2 with HBP
|
||||||
; r2x = Replicator 2X
|
; r2x = Replicator 2X
|
||||||
|
|
||||||
machine_type=r2
|
machine_type=r2
|
||||||
|
|
||||||
|
|
||||||
; GCODE FLAVOR
|
; GCODE FLAVOR
|
||||||
;
|
;
|
||||||
; specify the gcode flavor
|
; specify the gcode flavor
|
||||||
|
|
Loading…
Reference in New Issue