* @remarks The @psk is exchanged over a websocket connection.
* @since_tizen 6.5
* @param[in] security The security handle.
- * @param[in] psk The preshared key
+ * @param[in] psk The preshared key. This is limited to the maximum 512 characters.
* @return 0 on success, otherwise a negative error value
* @retval #VINE_ERROR_NONE Successful
* @retval #VINE_ERROR_INVALID_PARAMTER Invalid parameter
int data_len, const unsigned char *data, int *size)
{
*size = 5 + data_len;
- unsigned char *buf = new unsigned char[*size];
+ unsigned char *buf = (unsigned char *)calloc(*size, sizeof(unsigned char));
if (buf == NULL) {
VINE_LOGE("Out of memory");
return NULL;
void release_auth_frame(unsigned char *buf)
{
- delete [] buf;
+ free(buf);
}
bool parse_auth_frame(unsigned char *buf, size_t buf_size,
#include "vine-log.h"
#include "vine-utils.h"
+#define VINE_SECURITY_PSK_MAX_LEN 512
+
typedef struct {
vine_security_type_e type;
int flags;
{
RET_VAL_IF(security == NULL, VINE_ERROR_INVALID_PARAMETER, "security is NULL");
RET_VAL_IF(psk == NULL, VINE_ERROR_INVALID_PARAMETER, "psk is NULL");
+ RET_VAL_IF(strlen(psk) > VINE_SECURITY_PSK_MAX_LEN,
+ VINE_ERROR_INVALID_PARAMETER, "psk should be less than or equal to 512");
vine_security_s *s = (vine_security_s *)security;
if (s->psk)