X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilccore%2Fsilcid.c;h=6e892c087b2a8dedb675bbf4206408873fe48637;hb=c1ad9c3e8978b0e1537b5bbdf89e385029429516;hp=6a7fb8f2c72c38c20902cd95f137045b61b32c00;hpb=9734af565c9da0fdf77fd93283d7adcd8eb34b80;p=silc.git diff --git a/lib/silccore/silcid.c b/lib/silccore/silcid.c index 6a7fb8f2..6e892c08 100644 --- a/lib/silccore/silcid.c +++ b/lib/silccore/silcid.c @@ -62,6 +62,9 @@ SilcIDPayload silc_id_payload_parse(const unsigned char *payload, if (ret == -1) goto err; + if (newp->type > SILC_ID_CHANNEL) + goto err; + silc_buffer_pull(&buffer, 4); if (newp->len > buffer.len || newp->len > SILC_PACKET_MAX_ID_LEN) @@ -102,6 +105,9 @@ void *silc_id_payload_parse_id(const unsigned char *data, SilcUInt32 len, if (ret == -1) return NULL; + if (type > SILC_ID_CHANNEL) + return NULL; + silc_buffer_pull(&buffer, 4); if (idlen > buffer.len || idlen > SILC_PACKET_MAX_ID_LEN) @@ -209,6 +215,9 @@ unsigned char *silc_id_id2str(const void *id, SilcIdType type) SilcChannelID *channel_id; SilcUInt32 id_len = silc_id_get_len(id, type); + if (id_len > SILC_PACKET_MAX_ID_LEN) + return NULL; + switch(type) { case SILC_ID_SERVER: server_id = (SilcServerID *)id; @@ -251,6 +260,8 @@ unsigned char *silc_id_id2str(const void *id, SilcIdType type) void *silc_id_str2id(const unsigned char *id, SilcUInt32 id_len, SilcIdType type) { + if (id_len > SILC_PACKET_MAX_ID_LEN) + return NULL; switch(type) { case SILC_ID_SERVER: