@@ -212,19 +212,19 @@ int DNSResolver::resolve_ip_addr(CephContext *cct, const string& hostname,
212212int DNSResolver::resolve_ip_addr (CephContext *cct, res_state *res, const string& hostname,
213213 entity_addr_t *addr) {
214214
215- u_char nsbuf[NS_PACKETSZ] ;
215+ auto nsbuf = std::make_unique<std::array<u_char, NS_MAXMSG>>() ;
216216 int len;
217217 int family = cct->_conf ->ms_bind_ipv6 ? AF_INET6 : AF_INET;
218218 int type = cct->_conf ->ms_bind_ipv6 ? ns_t_aaaa : ns_t_a;
219219
220220#ifdef HAVE_RES_NQUERY
221- len = resolv_h->res_nquery (*res, hostname.c_str (), ns_c_in, type, nsbuf, sizeof ( nsbuf));
221+ len = resolv_h->res_nquery (*res, hostname.c_str (), ns_c_in, type, nsbuf-> data (), nsbuf-> size ( ));
222222#else
223223 {
224224# ifndef HAVE_THREAD_SAFE_RES_QUERY
225225 std::lock_guard l (lock);
226226# endif
227- len = resolv_h->res_query (hostname.c_str (), ns_c_in, type, nsbuf, sizeof ( nsbuf));
227+ len = resolv_h->res_query (hostname.c_str (), ns_c_in, type, nsbuf-> data (), nsbuf-> size ( ));
228228 }
229229#endif
230230 if (len < 0 ) {
@@ -237,7 +237,7 @@ int DNSResolver::resolve_ip_addr(CephContext *cct, res_state *res, const string&
237237 }
238238
239239 ns_msg handle;
240- ns_initparse (nsbuf, len, &handle);
240+ ns_initparse (nsbuf-> data () , len, &handle);
241241
242242 if (ns_msg_count (handle, ns_s_an) == 0 ) {
243243 ldout (cct, 20 ) << " no address found for hostname " << hostname << dendl;
@@ -285,7 +285,7 @@ int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
285285 });
286286#endif
287287
288- u_char nsbuf[NS_PACKETSZ] ;
288+ auto nsbuf = std::make_unique<std::array<u_char, NS_MAXMSG>>() ;
289289 int num_hosts;
290290
291291 string proto_str = srv_protocol_to_str (trans_protocol);
@@ -294,15 +294,15 @@ int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
294294 int len;
295295
296296#ifdef HAVE_RES_NQUERY
297- len = resolv_h->res_nsearch (res, query_str.c_str (), ns_c_in, ns_t_srv, nsbuf,
298- sizeof ( nsbuf));
297+ len = resolv_h->res_nsearch (res, query_str.c_str (), ns_c_in, ns_t_srv, nsbuf-> data () ,
298+ nsbuf-> size ( ));
299299#else
300300 {
301301# ifndef HAVE_THREAD_SAFE_RES_QUERY
302302 std::lock_guard l (lock);
303303# endif
304- len = resolv_h->res_search (query_str.c_str (), ns_c_in, ns_t_srv, nsbuf,
305- sizeof ( nsbuf));
304+ len = resolv_h->res_search (query_str.c_str (), ns_c_in, ns_t_srv, nsbuf-> data () ,
305+ nsbuf-> size ( ));
306306 }
307307#endif
308308 if (len < 0 ) {
@@ -316,7 +316,7 @@ int DNSResolver::resolve_srv_hosts(CephContext *cct, const string& service_name,
316316
317317 ns_msg handle;
318318
319- ns_initparse (nsbuf, len, &handle);
319+ ns_initparse (nsbuf-> data () , len, &handle);
320320
321321 num_hosts = ns_msg_count (handle, ns_s_an);
322322 if (num_hosts == 0 ) {
0 commit comments