Skip to content

Commit 17cff2f

Browse files
committed
Malloc cert and key contents
1 parent 23d75fc commit 17cff2f

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

Firmware/RTK_Surveyor/menuPP.ino

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,22 @@ bool provisionDevice()
278278
}
279279

280280
//Subscribe to MQTT channel, grab keys, then stop
281+
281282
bool updatePointPerfectKeys()
282283
{
283284
#ifdef COMPILE_WIFI
284285

285286
WiFiClientSecure secureClient;
286287

288+
#define CONTENT_SIZE 2000
289+
290+
certificateContents = (char*)malloc(CONTENT_SIZE);
291+
memset(certificateContents, 0, CONTENT_SIZE);
287292
loadFile("certificate", certificateContents);
288293
secureClient.setCertificate(certificateContents);
289294

295+
keyContents = (char*)malloc(CONTENT_SIZE);
296+
memset(keyContents, 0, CONTENT_SIZE);
290297
loadFile("privateKey", keyContents);
291298
secureClient.setPrivateKey(keyContents);
292299

@@ -336,6 +343,8 @@ bool updatePointPerfectKeys()
336343
if (mqttClient.connected() == false)
337344
{
338345
log_d("Client disconnected");
346+
free(certificateContents);
347+
free(keyContents);
339348
return (false);
340349
}
341350

@@ -345,12 +354,16 @@ bool updatePointPerfectKeys()
345354
{
346355
Serial.println();
347356
log_d("Channel failed to respond");
357+
free(certificateContents);
358+
free(keyContents);
348359
return (false);
349360
}
350361
}
351362

352363
Serial.println();
353-
Serial.println("Keys successfully update");
364+
Serial.println("Keys successfully updated");
365+
free(certificateContents);
366+
free(keyContents);
354367
return (true);
355368
#else
356369
return (false);
@@ -957,8 +970,6 @@ void menuPointPerfect()
957970
else
958971
updatePointPerfectKeys();
959972
}
960-
961-
bluetoothStart();
962973
#endif
963974
}
964975
else if (incoming == '6')

0 commit comments

Comments
 (0)