Bug #764

sscanf() does not support integer variables of a specific size

Added by Jörg Riesmeier 4 months ago. Updated 4 months ago.

Status:New Start date:2017-06-23
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:Library
Target version:3.6.3
Module: Compiler:
Operating System:

Description

At various places in the DCMTK, sscanf() is used to convert character string into an integer value. The current approach...

    Uint32 value = 0;
#if SIZEOF_LONG == 8
    if (sscanf(ptr, "%u", &value) == 1)
#else
    if (sscanf(ptr, "%lu", &value) == 1)
#endif

... is not 100% portable when the integer variable has a specific size (number of bits), e.g. Uint32 or Sint32. This first showed up on a 32-bit Linux (Debian) system. Not sure whether this only happens when C++11 support is enabled.

Maybe, there should be something like OFStandard::sscanUint32() and OFStandard::sscanSint32(), i.e. global functions that provide this functionality.

History

#1 Updated by Jörg Riesmeier 4 months ago

  • Description updated (diff)

#2 Updated by Jörg Riesmeier 4 months ago

  • Description updated (diff)

Also available in: Atom PDF