summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorнаб <nabijaczleweli@nabijaczleweli.xyz>2024-11-11 15:43:56 +0100
committerнаб <nabijaczleweli@nabijaczleweli.xyz>2024-11-11 16:34:58 +0100
commit4438f9defcd18bc1ded87f69d9ab8f6441218ec4 (patch)
tree325d8f46ef2af6849bf9706b3be98a26533f0e50
parentaefccbe09722c6a7a0911cb882622c96215eeec2 (diff)
Replace constant-size never-reallicated getservbyport_r() std::vector buffer with std::array
-rw-r--r--apt-pkg/contrib/srvrec.cc3
1 files changed, 2 insertions, 1 deletions
diff --git a/apt-pkg/contrib/srvrec.cc b/apt-pkg/contrib/srvrec.cc
index 4a68f3578..3ddb95abb 100644
--- a/apt-pkg/contrib/srvrec.cc
+++ b/apt-pkg/contrib/srvrec.cc
@@ -16,6 +16,7 @@
#include <netinet/in.h>
#include <resolv.h>
+#include <array>
#include <algorithm>
#include <memory>
#include <tuple>
@@ -47,7 +48,7 @@ bool GetSrvRecords(std::string host, int port, std::vector<SrvRec> &Result)
int res;
struct servent s_ent_buf;
struct servent *s_ent = nullptr;
- std::vector<char> buf(1024);
+ std::array<char, 1024> buf;
res = getservbyport_r(htons(port), "tcp", &s_ent_buf, buf.data(), buf.size(), &s_ent);
if (res != 0 || s_ent == nullptr)