microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.91k stars 1.64k forks source link

Unused offset parameter in _seekrdtoend_fsb #1703

Open NN--- opened 2 years ago

NN--- commented 2 years ago

https://github.com/microsoft/cpprestsdk/commit/3f6f84461a74fb2d6d37b31e737711b5f83c2f66#diff-6c5e46029d14fa484c700918487121a72cd648b14dd43d728e1527df748d84e6R908 adds Win64 support. But the code in Win64 build ignores the offset parameter entirely.

#ifdef _WIN64
    // Unused in this #if branch !!!
    LARGE_INTEGER filesize;
    filesize.QuadPart = 0;

    BOOL result = GetFileSizeEx(fInfo->m_handle, &filesize);
    if (FALSE == result)
    {
        return static_cast<size_t>(-1);
    }
    else
    {
        fInfo->m_rdpos = static_cast<size_t>(filesize.QuadPart) / char_size;
    }
#else
    // Used in the line below
    auto newpos = SetFilePointer(fInfo->m_handle, (LONG)(offset * char_size), nullptr, FILE_END); 

    if (newpos == INVALID_SET_FILE_POINTER) return static_cast<size_t>(-1);

    fInfo->m_rdpos = static_cast<size_t>(newpos) / char_size;
#endif