mirror of
https://github.com/nmap/nmap.git
synced 2026-05-13 08:46:45 +00:00
Get correct errors from Windows on failure (errno is not set). See #978
This commit is contained in:
parent
3c91ad69b4
commit
d0718cd631
2 changed files with 11 additions and 1 deletions
|
|
@ -213,7 +213,6 @@
|
|||
<ClInclude Include="base64.h" />
|
||||
<ClInclude Include="http.h" />
|
||||
<ClInclude Include="..\mswin32\ifaddrlist.h" />
|
||||
<ClInclude Include="..\mswin32\IPExport.h" />
|
||||
<ClInclude Include="ncat.h" />
|
||||
<ClInclude Include="ncat_connect.h" />
|
||||
<ClInclude Include="ncat_core.h" />
|
||||
|
|
|
|||
11
ncat/util.c
11
ncat/util.c
|
|
@ -235,7 +235,18 @@ void logtest(const char *fmt, ...)
|
|||
/* Exit status 2 indicates a program error other than a network error. */
|
||||
void die(char *err)
|
||||
{
|
||||
#ifdef WIN32
|
||||
int error_number;
|
||||
char *strerror_s;
|
||||
error_number = GetLastError();
|
||||
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
|
||||
NULL, error_number, MAKELANGID (LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR) &strerror_s, 0, NULL);
|
||||
fprintf(stderr, "%s: %s\n", err, strerror_s);
|
||||
HeapFree(GetProcessHeap(), 0, strerror_s);
|
||||
#else
|
||||
perror(err);
|
||||
#endif
|
||||
fflush(stderr);
|
||||
exit(2);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue