View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0033241 | Open CASCADE | OCCT:Foundation Classes | public | 2022-11-30 15:36 | 2024-06-13 13:57 |
| Reporter | Assigned To | dpasukhi | |||
| Priority | normal | Severity | minor | ||
| Status | new | Resolution | open | ||
| Platform | Windows | OS | VC++ 2017 | ||
| Target Version | Unscheduled | ||||
| Summary | 0033241: Foundation Classes - unrealized support for socket type of OSD_File leads to linking of an unused winsock library | ||||
| Description | The issure 0033235 was resolved by linking wsock32.lib I found that the only reason to linking this lib is the call of "recv" function in OSD_File_getBuffer in OSD_File.cxx But I can't find any traces of socket use such as WSA* functions and any Berkeley socket functions. The only atemp to read OSD_File as socket is than parameter theIsSocket is true. In turn, the parameter theIsSocket is true only if myIO member of OSD_File has FLAG_SOCKET flag. The FLAG_SOCKET flag is generated only by _get_file_type function but it does it with mistake. It uses return of windows api GetFileType function:
const int aFileType = theFileHandle == INVALID_HANDLE_VALUE
? FILE_TYPE_DISK
: GetFileType (theFileHandle);
switch (aFileType)
{
case FILE_TYPE_UNKNOWN:
return FLAG_SOCKET;
case FILE_TYPE_DISK:
{
const TCollection_ExtendedString aFileNameW (theFileName, Standard_True);
WIN32_FILE_ATTRIBUTE_DATA aFileInfo;
if (GetFileAttributesExW (aFileNameW.ToWideString(), GetFileExInfoStandard, &aFileInfo))
{
return aFileInfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ? FLAG_DIRECTORY : FLAG_FILE;
}
return 0x80000000;
}
case FILE_TYPE_CHAR:
return FLAG_DEVICE;
case FILE_TYPE_PIPE:
return FLAG_PIPE;
}
But documentation of GetFileType says: FILE_TYPE_PIPE - The specified file is a socket, a named pipe, or an anonymous pipe. FILE_TYPE_UNKNOWN - Either the type of the specified file is unknown, or the function failed. https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getfiletype So, I see three things: 1) OSD_File never create a socket by WSASocket or socket (to create a socket there should be WSAStartup call before) 2) OSD_File never can own a windows socket handle 3) FLAG_SOCKET and OSD_SOCKET macros are some kind of rudiment of old life. ... and I suggest three things: 1) To remove the unrealized support of sockets from code 2) To review the support of pipes 3) To remove the linking of wsock32.lib from all executables | ||||
| Tags | No tags attached. | ||||
| Test case number | |||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2022-11-30 15:36 |
|
New Issue | |
| 2022-11-30 15:36 |
|
Assigned To | => abv |
| 2022-11-30 15:37 |
|
Description Updated | |
| 2022-11-30 15:40 |
|
Description Updated | |
| 2022-11-30 15:40 |
|
Relationship added | related to 0033235 |
| 2022-12-01 11:14 |
|
Assigned To | abv => msv |
| 2023-03-06 19:38 | ebelouso | Target Version | 7.7.1 => Unscheduled |
| 2024-06-13 13:57 | dpasukhi | Assigned To | msv => dpasukhi |