Browse Source

Intermediate changes

robot-piglet 1 year ago
parent
commit
c88ff01faa

+ 5 - 0
contrib/libs/pybind11/include/pybind11/pytypes.h

@@ -265,6 +265,11 @@ public:
         this function automatically. Returns a reference to itself.
     \endrst */
     const handle &dec_ref() const & {
+#ifdef Py_DEBUG
+        if (!Py_IsInitialized()) {
+            return *this;
+        }
+#endif
 #ifdef PYBIND11_ASSERT_GIL_HELD_INCREF_DECREF
         if (m_ptr != nullptr && !PyGILState_Check()) {
             throw_gilstate_error("pybind11::handle::dec_ref()");

+ 3 - 3
library/cpp/netliba/v6/udp_address.cpp

@@ -278,7 +278,7 @@ namespace NNetliba {
         char buf[1000];
         if (addr.IsIPv4()) {
             int ip = addr.GetIPv4();
-            sprintf(buf, "%d.%d.%d.%d:%d",
+            snprintf(buf, sizeof(buf), "%d.%d.%d.%d:%d",
                     (ip >> 0) & 0xff, (ip >> 8) & 0xff,
                     (ip >> 16) & 0xff, (ip >> 24) & 0xff,
                     addr.Port);
@@ -288,9 +288,9 @@ namespace NNetliba {
             *BreakAliasing<ui64>(ipv6 + 4) = addr.Interface;
             char suffix[100] = "";
             if (addr.Scope != 0) {
-                sprintf(suffix, "%%%d", addr.Scope);
+                snprintf(suffix, sizeof(suffix), "%%%d", addr.Scope);
             }
-            sprintf(buf, "[%x:%x:%x:%x:%x:%x:%x:%x%s]:%d",
+            snprintf(buf, sizeof(buf), "[%x:%x:%x:%x:%x:%x:%x:%x%s]:%d",
                     ntohs(ipv6[0]), ntohs(ipv6[1]), ntohs(ipv6[2]), ntohs(ipv6[3]),
                     ntohs(ipv6[4]), ntohs(ipv6[5]), ntohs(ipv6[6]), ntohs(ipv6[7]),
                     suffix, addr.Port);

+ 5 - 5
library/cpp/netliba/v6/udp_client_server.cpp

@@ -1214,7 +1214,7 @@ namespace NNetliba {
             const TUdpAddress& ip = i.first;
             const TCongestionControl& cc = *i.second.UdpCongestion;
             IIBPeer* ibPeer = i.second.IBPeer.Get();
-            sprintf(buf, "%s\tIB: %d, RTT: %g  Timeout: %g  Window: %g  MaxWin: %g  FailRate: %g  TimeSinceLastRecv: %g  Transfers: %d  MTU: %d\n",
+            snprintf(buf, sizeof(buf), "%s\tIB: %d, RTT: %g  Timeout: %g  Window: %g  MaxWin: %g  FailRate: %g  TimeSinceLastRecv: %g  Transfers: %d  MTU: %d\n",
                     GetAddressAsString(ip).c_str(),
                     ibPeer ? ibPeer->GetState() : -1,
                     cc.GetRTT() * 1000, cc.GetTimeout() * 1000, cc.GetWindow(), cc.GetMaxWindow(), cc.GetFailRate(),
@@ -1227,17 +1227,17 @@ namespace NNetliba {
     TString TUdpHost::GetDebugInfo() {
         TString res;
         char buf[1000];
-        sprintf(buf, "Receiving %d msgs, sending %d high prior, %d regular msgs, %d low prior msgs\n",
+        snprintf(buf, sizeof(buf), "Receiving %d msgs, sending %d high prior, %d regular msgs, %d low prior msgs\n",
                 RecvQueue.ysize(), (int)SendOrderHighPrior.size(), (int)SendOrder.size(), (int)SendOrderLow.size());
         res += buf;
 
         TRequesterPendingDataStats pds;
         GetPendingDataSize(&pds);
-        sprintf(buf, "Pending data size: %" PRIu64 "\n", pds.InpDataSize + pds.OutDataSize);
+        snprintf(buf, sizeof(buf), "Pending data size: %" PRIu64 "\n", pds.InpDataSize + pds.OutDataSize);
         res += buf;
-        sprintf(buf, "  in packets: %d, size %" PRIu64 "\n", pds.InpCount, pds.InpDataSize);
+        snprintf(buf, sizeof(buf), "  in packets: %d, size %" PRIu64 "\n", pds.InpCount, pds.InpDataSize);
         res += buf;
-        sprintf(buf, "  out packets: %d, size %" PRIu64 "\n", pds.OutCount, pds.OutDataSize);
+        snprintf(buf, sizeof(buf), "  out packets: %d, size %" PRIu64 "\n", pds.OutCount, pds.OutDataSize);
         res += buf;
 
         res += "\nCongestion info:\n";

+ 4 - 4
library/cpp/netliba/v6/udp_http.cpp

@@ -1041,9 +1041,9 @@ namespace NNetliba {
 
             char buf[1000];
             TRequesterUserQueueSizes* qs = QueueSizes.Get();
-            sprintf(buf, "\nRequest queue %d (%d bytes)\n", (int)AtomicGet(qs->ReqCount), (int)AtomicGet(qs->ReqQueueSize));
+            snprintf(buf, sizeof(buf), "\nRequest queue %d (%d bytes)\n", (int)AtomicGet(qs->ReqCount), (int)AtomicGet(qs->ReqQueueSize));
             res += buf;
-            sprintf(buf, "Response queue %d (%d bytes)\n", (int)AtomicGet(qs->RespCount), (int)AtomicGet(qs->RespQueueSize));
+            snprintf(buf, sizeof(buf), "Response queue %d (%d bytes)\n", (int)AtomicGet(qs->RespCount), (int)AtomicGet(qs->RespQueueSize));
             res += buf;
 
             const char* outReqStateNames[] = {
@@ -1061,7 +1061,7 @@ namespace NNetliba {
                 const TGUID& gg = i->first;
                 const TOutRequestState& s = i->second;
                 bool isSync = SyncRequests.find(gg) != SyncRequests.end();
-                sprintf(buf, "%s\t%s  %s  TimePassed: %g  %s\n",
+                snprintf(buf, sizeof(buf), "%s\t%s  %s  TimePassed: %g  %s\n",
                         GetAddressAsString(s.Address).c_str(), GetGuidAsString(gg).c_str(), outReqStateNames[s.State],
                         s.TimePassed * 1000,
                         isSync ? "isSync" : "");
@@ -1071,7 +1071,7 @@ namespace NNetliba {
             for (TInRequestHash::const_iterator i = InRequests.begin(); i != InRequests.end(); ++i) {
                 const TGUID& gg = i->first;
                 const TInRequestState& s = i->second;
-                sprintf(buf, "%s\t%s  %s\n",
+                snprintf(buf, sizeof(buf), "%s\t%s  %s\n",
                         GetAddressAsString(s.Address).c_str(), GetGuidAsString(gg).c_str(), inReqStateNames[s.State]);
                 res += buf;
             }