Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix buffer overflow in LCD_disp_str #245

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/lcd.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ typedef struct __attribute__ ((packed)) {
void charoutsmall(uint8_t theChar, uint8_t X, uint8_t Y) {
// First of all, make lowercase into uppercase
// (as there are no lowercase letters in the font)
if (theChar < 0x20)
return;
if ((theChar & 0x7f) >= 0x61 && (theChar & 0x7f) <= 0x7a) {
theChar -= 0x20;
}
Expand Down Expand Up @@ -86,13 +88,13 @@ void charoutsmall(uint8_t theChar, uint8_t X, uint8_t Y) {

void LCD_disp_str(uint8_t* theStr, uint8_t theLen, uint8_t startx, uint8_t y, uint8_t theFormat) {
#ifdef MINIMALISTIC
for (uint8_t q = 0; q < theLen; q++) {
for (uint8_t q = 0; q < theLen && theStr[q]; q++) {
charoutsmall(theStr[q], startx, y);
startx += 6;
}
#else
uint8_t invmask = theFormat & 0x80;
for(uint8_t q = 0; q < theLen; q++) {
for(uint8_t q = 0; q < theLen && theStr[q]; q++) {
charoutsmall(theStr[q] | invmask, startx, y);
startx += 6;
}
Expand Down
17 changes: 17 additions & 0 deletions src/reflow_profiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,22 @@

extern uint8_t graphbmp[];

// SAC305 profile
static const profile sac305profile = {
"SAC305 Leadfree", {
// Preheat
50, 65, 80, 90, 92, 94, 96, 97, 98, 99, 100, 100,
105, 115, 125, 135, 140,
// Flux activation
145, 150, 155, 160, 165, 170, 175, 180,
// reflow peak
195, 210, 235, 245, 225, 205, 185, 165,
// cool down
155, 145, 140, 135, 130, 125, 120, 115, 110, 105, 100,
0, 0 // 360-470 s
}
};

// Amtech 4300 63Sn/37Pb leaded profile
static const profile am4300profile = {
"4300 63SN/37PB", {
Expand Down Expand Up @@ -70,6 +86,7 @@ static ramprofile ee1 = { "CUSTOM #1" };
static ramprofile ee2 = { "CUSTOM #2" };

static const profile* profiles[] = {
&sac305profile,
&syntechlfprofile,
&nc31profile,
&am4300profile,
Expand Down
4 changes: 2 additions & 2 deletions src/sensor.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@ void Sensor_ValidateNV(void) {
temp = 100;
NV_SetConfig(TC_LEFT_OFFSET, temp); // Default +/-0 offset
}
adcoffsetadj[0] = ((float)(temp - 100)) * 0.25f;
adcoffsetadj[0] = ((float)(temp - 127)) * 0.5f;

temp = NV_GetConfig(TC_RIGHT_OFFSET);
if (temp == 255) {
temp = 100;
NV_SetConfig(TC_RIGHT_OFFSET, temp); // Default +/-0 offset
}
adcoffsetadj[1] = ((float)(temp - 100)) * 0.25f;
adcoffsetadj[1] = ((float)(temp - 127)) * 0.5f;
}


Expand Down
4 changes: 2 additions & 2 deletions src/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ static setupMenuStruct setupmenu[] = {
{"Min fan speed %4.0f", REFLOW_MIN_FAN_SPEED, 0, 254, 0, 1.0f},
{"Cycle done beep %4.1fs", REFLOW_BEEP_DONE_LEN, 0, 254, 0, 0.1f},
{"Left TC gain %1.2f", TC_LEFT_GAIN, 10, 190, 0, 0.01f},
{"Left TC offset %+1.2f", TC_LEFT_OFFSET, 0, 200, -100, 0.25f},
{"Left TC offset %+1.1f", TC_LEFT_OFFSET, 0, 254, -127, 0.5f},
{"Right TC gain %1.2f", TC_RIGHT_GAIN, 10, 190, 0, 0.01f},
{"Right TC offset %+1.2f", TC_RIGHT_OFFSET, 0, 200, -100, 0.25f},
{"Right TC offset %+1.1f", TC_RIGHT_OFFSET, 0, 254, -127, 0.5f},
};
#define NUM_SETUP_ITEMS (sizeof(setupmenu) / sizeof(setupmenu[0]))

Expand Down