BBS:      TELESC.NET.BR
Assunto:  src/xpdev/sockwrap.c
De:       Rob Swindell (on Windows 11)
Data:     Sat, 2 May 2026 18:58:15 -0700
-----------------------------------------------------------
https://gitlab.synchro.net/main/sbbs/-/commit/9bb6aa39080f6af5c62a2166
Modified Files:
	src/xpdev/sockwrap.c
Log Message:
sockwrap: preserve WSAGetLastError() across socket_strerror()

On Windows, FormatMessageA() shares its TLS slot with WSAGetLastError(),
and calls SetLastError(ERROR_INSUFFICIENT_BUFFER) on a too-small buffer.
Callers that reference SOCKET_ERRNO and SOCKET_STRERROR in the same
printf-style call (e.g. main.cpp:2745, telgate.cpp:433) can therefore
see a bogus normalized error code (e.g. -9878 from 122-WSABASEERR) when
argument-evaluation order puts the SOCKET_STRERROR call first and the
underlying message overflows the caller's buffer.

Snapshot WSAGetLastError() at function entry and restore it before
returning so the side-effect cannot leak.

Co-Authored-By: Claude Opus 4.7 (1M context) 
n
---
  mSynchronetn  hgVertrauen n hHome of Synchronet n gh[vert/cvs/bbs].synchro.net

-----------------------------------------------------------
[Voltar]