cpprestsdk icon indicating copy to clipboard operation
cpprestsdk copied to clipboard

Unused offset parameter in _seekrdtoend_fsb

Open NN--- opened this issue 2 years ago • 0 comments

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

NN--- avatar May 09 '22 20:05 NN---