Skip to content
Snippets Groups Projects
Commit c78fd7aa authored by Hauke Mehrtens's avatar Hauke Mehrtens
Browse files

BLE: FileTrans: Null terminate the original buffer.


We get a pointer to our own buffer back and we made it 1 byte longer, so
we can simply null terminate the buffer.

Signed-off-by: default avatarHauke Mehrtens <hauke@hauke-m.de>
parent 803d37ef
No related branches found
No related tags found
No related merge requests found
...@@ -257,21 +257,12 @@ static int bleFileCreateOrOpen(char *filepath) ...@@ -257,21 +257,12 @@ static int bleFileCreateOrOpen(char *filepath)
static uint8_t bleFileOpen(dmConnId_t connId, uint8_t *pValue, uint16_t len) static uint8_t bleFileOpen(dmConnId_t connId, uint8_t *pValue, uint16_t len)
{ {
char filepath[100]; pValue[len] = 0;
if (len > sizeof(filepath)) {
sendCrcResponse(connId, 'e', 0, NULL, "path too long");
return ATT_ERR_RESOURCES;
}
/* Copy only file path and not type, make sure this is NULL terminated */
strncpy(filepath, (char *)pValue + 1, len - 1);
filepath[len - 1] = 0;
if (file_fd != -1) if (file_fd != -1)
epic_file_close(file_fd); epic_file_close(file_fd);
file_fd = bleFileCreateOrOpen(filepath); file_fd = bleFileCreateOrOpen((char *)pValue);
if (file_fd < 0) { if (file_fd < 0) {
sendCrcResponse(connId, 'e', 0, NULL, "open failed"); sendCrcResponse(connId, 'e', 0, NULL, "open failed");
return ATT_ERR_RESOURCES; return ATT_ERR_RESOURCES;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment