mirror of https://github.com/ARMmbed/mbed-os.git
fix signed writes
parent
c4afea26fa
commit
d3bda92bee
|
@ -167,30 +167,47 @@ static void attsProcSignedWrite(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
|
||||||
/* find attribute */
|
/* find attribute */
|
||||||
if ((pAttr = attsFindByHandle(handle, &pGroup)) != NULL)
|
if ((pAttr = attsFindByHandle(handle, &pGroup)) != NULL)
|
||||||
{
|
{
|
||||||
/* verify permissions */
|
|
||||||
if (attsPermissions(pCcb->connId, ATTS_PERMIT_WRITE, handle, pAttr->permissions) != ATT_SUCCESS)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/* verify signed write is permitted */
|
/* verify signed write is permitted */
|
||||||
else if ((pAttr->settings & ATTS_SET_ALLOW_SIGNED) == 0)
|
if ((pAttr->settings & ATTS_SET_ALLOW_SIGNED) == 0)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* verify that csrk is present */
|
||||||
|
if (attsSignCcbByConnId(pCcb->pMainCcb->connId)->pCsrk == NULL) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* verify basic permissions */
|
||||||
|
if ((pAttr->permissions & (ATTS_PERMIT_WRITE | ATTS_PERMIT_WRITE_ENC)) == 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* verify authentication */
|
||||||
|
if ((pAttr->permissions & ATTS_PERMIT_WRITE_AUTH) &&
|
||||||
|
(attsSignCcbByConnId(pCcb->pMainCcb->connId)->authenticated == 0))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Note: authorization not verified at this stage as it is reserved for lesc
|
||||||
|
writes; authorization occurs latter when the write cb is called */
|
||||||
|
|
||||||
/* verify write length, fixed length */
|
/* verify write length, fixed length */
|
||||||
else if (((pAttr->settings & ATTS_SET_VARIABLE_LEN) == 0) &&
|
if (((pAttr->settings & ATTS_SET_VARIABLE_LEN) == 0) &&
|
||||||
(writeLen != pAttr->maxLen))
|
(writeLen != pAttr->maxLen))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* verify write length, variable length */
|
/* verify write length, variable length */
|
||||||
else if (((pAttr->settings & ATTS_SET_VARIABLE_LEN) != 0) &&
|
if (((pAttr->settings & ATTS_SET_VARIABLE_LEN) != 0) &&
|
||||||
(writeLen > pAttr->maxLen))
|
(writeLen > pAttr->maxLen))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
/* allocate buffer to store packet and parameters */
|
/* allocate buffer to store packet and parameters */
|
||||||
if ((pBuf = WsfBufAlloc(sizeof(attsSignBuf_t) - 1 + len)) != NULL)
|
if ((pBuf = WsfBufAlloc(sizeof(attsSignBuf_t) - 1 + len)) != NULL)
|
||||||
{
|
{
|
||||||
|
@ -217,7 +234,6 @@ static void attsProcSignedWrite(attsCcb_t *pCcb, uint16_t len, uint8_t *pPacket)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/*************************************************************************************************/
|
/*************************************************************************************************/
|
||||||
/*!
|
/*!
|
||||||
|
|
Loading…
Reference in New Issue