FS-9775: Replaced initialization of nodeid to use safer passing through raw fixed size type
This commit is contained in:
parent
ed8e4dc610
commit
61e1545e8f
|
@ -57,7 +57,7 @@ KS_DECLARE(ks_status_t) ks_dht2_free(ks_dht2_t *dht)
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const uint8_t *nodeid)
|
KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const ks_dht2_nodeid_raw_t *nodeid)
|
||||||
{
|
{
|
||||||
ks_assert(dht);
|
ks_assert(dht);
|
||||||
ks_assert(dht->pool);
|
ks_assert(dht->pool);
|
||||||
|
@ -392,7 +392,7 @@ KS_DECLARE(ks_status_t) ks_dht2_process_query_ping(ks_dht2_t *dht, ks_sockaddr_t
|
||||||
return KS_STATUS_FAIL;
|
return KS_STATUS_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ks_dht2_nodeid_init(&nid, (const uint8_t *)idv) != KS_STATUS_SUCCESS) {
|
if (ks_dht2_nodeid_init(&nid, (const ks_dht2_nodeid_raw_t *)idv) != KS_STATUS_SUCCESS) {
|
||||||
return KS_STATUS_FAIL;
|
return KS_STATUS_FAIL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,7 @@ KS_DECLARE(ks_status_t) ks_dht2_prealloc(ks_dht2_t *dht, ks_pool_t *pool);
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_free(ks_dht2_t *dht);
|
KS_DECLARE(ks_status_t) ks_dht2_free(ks_dht2_t *dht);
|
||||||
|
|
||||||
|
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const uint8_t *nodeid);
|
KS_DECLARE(ks_status_t) ks_dht2_init(ks_dht2_t *dht, const ks_dht2_nodeid_raw_t *nodeid);
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_deinit(ks_dht2_t *dht);
|
KS_DECLARE(ks_status_t) ks_dht2_deinit(ks_dht2_t *dht);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -47,7 +47,7 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_free(ks_dht2_nodeid_t *nodeid)
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const uint8_t *id)
|
KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const ks_dht2_nodeid_raw_t *id)
|
||||||
{
|
{
|
||||||
ks_assert(nodeid);
|
ks_assert(nodeid);
|
||||||
ks_assert(nodeid->pool);
|
ks_assert(nodeid->pool);
|
||||||
|
@ -55,7 +55,7 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const uint
|
||||||
if (!id) {
|
if (!id) {
|
||||||
randombytes_buf(nodeid->id, KS_DHT_NODEID_LENGTH);
|
randombytes_buf(nodeid->id, KS_DHT_NODEID_LENGTH);
|
||||||
} else {
|
} else {
|
||||||
memcpy(nodeid->id, id, KS_DHT_NODEID_LENGTH);
|
memcpy(nodeid->id, id->id, KS_DHT_NODEID_LENGTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
return KS_STATUS_SUCCESS;
|
return KS_STATUS_SUCCESS;
|
||||||
|
|
|
@ -7,6 +7,11 @@ KS_BEGIN_EXTERN_C
|
||||||
|
|
||||||
#define KS_DHT_NODEID_LENGTH 20
|
#define KS_DHT_NODEID_LENGTH 20
|
||||||
|
|
||||||
|
typedef struct ks_dht2_nodeid_raw_s ks_dht2_nodeid_raw_t;
|
||||||
|
struct ks_dht2_nodeid_raw_s {
|
||||||
|
uint8_t id[KS_DHT_NODEID_LENGTH];
|
||||||
|
};
|
||||||
|
|
||||||
typedef struct ks_dht2_nodeid_s ks_dht2_nodeid_t;
|
typedef struct ks_dht2_nodeid_s ks_dht2_nodeid_t;
|
||||||
struct ks_dht2_nodeid_s {
|
struct ks_dht2_nodeid_s {
|
||||||
ks_pool_t *pool;
|
ks_pool_t *pool;
|
||||||
|
@ -17,7 +22,7 @@ KS_DECLARE(ks_status_t) ks_dht2_nodeid_alloc(ks_dht2_nodeid_t **nodeid, ks_pool_
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_prealloc(ks_dht2_nodeid_t *nodeid, ks_pool_t *pool);
|
KS_DECLARE(ks_status_t) ks_dht2_nodeid_prealloc(ks_dht2_nodeid_t *nodeid, ks_pool_t *pool);
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_free(ks_dht2_nodeid_t *nodeid);
|
KS_DECLARE(ks_status_t) ks_dht2_nodeid_free(ks_dht2_nodeid_t *nodeid);
|
||||||
|
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const uint8_t *id);
|
KS_DECLARE(ks_status_t) ks_dht2_nodeid_init(ks_dht2_nodeid_t *nodeid, const ks_dht2_nodeid_raw_t *id);
|
||||||
KS_DECLARE(ks_status_t) ks_dht2_nodeid_deinit(ks_dht2_nodeid_t *nodeid);
|
KS_DECLARE(ks_status_t) ks_dht2_nodeid_deinit(ks_dht2_nodeid_t *nodeid);
|
||||||
|
|
||||||
KS_END_EXTERN_C
|
KS_END_EXTERN_C
|
||||||
|
|
Loading…
Reference in New Issue