11/*********************************************************************
2- * PicoTCP-NG
2+ * PicoTCP-NG
33 * Copyright (c) 2020 Daniele Lacamera <[email protected] > 44 *
55 * This file also includes code from:
66 * PicoTCP
77 * Copyright (c) 2012-2017 Altran Intelligent Systems
88 * Authors: Toon Stegen, Jelle De Vleeschouwer
9- *
9+ *
1010 * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only
1111 *
1212 * PicoTCP-NG is free software; you can redistribute it and/or modify
2626 *
2727 *********************************************************************/
2828#include "pico_config.h"
29+ #include "pico_dns_common.h"
2930#include "pico_stack.h"
3031#include "pico_addressing.h"
3132#include "pico_socket.h"
@@ -934,7 +935,7 @@ pico_mdns_record_delete( void **record )
934935 * Creates a single standalone mDNS resource record with given name, type and
935936 * data.
936937 *
937- * @param S TCP/IP stack reference
938+ * @param S TCP/IP stack reference
938939 * @param url DNS rrecord name in URL format. Will be converted to DNS
939940 * name notation format.
940941 * @param _rdata Memory buffer with data to insert in the resource record. If
@@ -1040,7 +1041,7 @@ pico_mdns_cookie_delete( void **ptr )
10401041/* ****************************************************************************
10411042 * Creates a single standalone mDNS cookie
10421043 *
1043- * @param S TCP/IP stack reference
1044+ * @param S TCP/IP stack reference
10441045 * @param qtree DNS questions you want to insert in the cookie.
10451046 * @param antree mDNS answers/authority records you want to add to cookie.
10461047 * @param artree mDNS additional records you want to add to cookie.
@@ -1050,7 +1051,7 @@ pico_mdns_cookie_delete( void **ptr )
10501051 * @return Pointer to newly create cookie, NULL on failure.
10511052 * ****************************************************************************/
10521053static struct pico_mdns_cookie *
1053- pico_mdns_cookie_create ( struct pico_stack * S ,
1054+ pico_mdns_cookie_create ( struct pico_stack * S ,
10541055 pico_dns_qtree qtree ,
10551056 pico_mdns_rtree antree ,
10561057 pico_mdns_rtree artree ,
@@ -1466,7 +1467,7 @@ pico_mdns_my_records_probed( pico_mdns_rtree *records )
14661467 PICO_FREE (record -> stack -> mdns_hostname );
14671468 }
14681469 /* Re-allocate hostname from given rname */
1469- record -> stack -> mdns_hostname =
1470+ record -> stack -> mdns_hostname =
14701471 pico_dns_qname_to_url (found -> record -> rname );
14711472 }
14721473
@@ -2190,6 +2191,12 @@ pico_mdns_handle_data_as_answers_generic(struct pico_stack *S,
21902191 return -1 ;
21912192 }
21922193
2194+ // check that the number of answare/response corrispond to the number of questions
2195+ if (count != pico_tree_count (& S -> MDNSOwnRecords )) {
2196+ mdns_dbg ("Number of answers does not match the number of questions\n" );
2197+ return -1 ;
2198+ }
2199+
21932200 /* TODO: When receiving multiple authoritative answers, */
21942201 /* they should be sorted in lexicographical order */
21952202 /* (just like in pico_mdns_record_am_i_lexi_later) */
@@ -3000,7 +3007,7 @@ pico_mdns_getrecord_generic(struct pico_stack *S, const char *url, uint16_t typ
30003007 }
30013008
30023009 /* Associate the current TCP/IP stack reference to access relevant
3003- * fields/trees
3010+ * fields/trees
30043011 */
30053012 q -> stack = S ;
30063013
0 commit comments