Menu

#525 sprintf_s is broken in v4

v1.0 (example)
open
nobody
None
5
2016-02-21
2016-01-10
robpats
No

I tried three builds.
i686-4.8.5-release-posix-dwarf-rt_v4-rev0.7z
i686-4.9.3-release-posix-dwarf-rt_v4-rev1.7z
i686-5.3.0-release-posix-dwarf-rt_v4-rev0.7z

sprintf_s fails silently in the following code.

g++ -o test.exe -static test.cpp
:::c++
#include <cstdio>

int main() {
    char buffer[128] = "";
    int value = sprintf_s(buffer, 128, "test");
    printf("%d: '%s'\n", value, buffer);
    return 0;
}

i686-4.8.4-release-posix-dwarf-rt_v3-rev0.7z does not have this bug.

Discussion

  • rossy

    rossy - 2016-02-19

    I think this is to do with the implementation of vsprintf_s. It incorrectly calls msvcrt's vprintf_s. See:
    https://github.com/mpv-player/mpv/issues/2743#issuecomment-186007525

    This causes trouble for us in mpv because it prints garbage to stdout.

     
  • Jonathan Yong

    Jonathan Yong - 2016-02-19

    Looks like the wrong function was loaded. Can you try the patch up in the ML? Thanks.

     
  • Jonathan Yong

    Jonathan Yong - 2016-02-19

    This should now be fixed on the master and v4.x branch.

     
  • rossy

    rossy - 2016-02-21

    Yep, that fixed it for mpv. Thanks for the fix.

     

Log in to post a comment.

MongoDB Logo MongoDB