Skip to content

Buggy handling of unsigned long in vsprintf_internal #270

@PwnVerse

Description

@PwnVerse

When compiling the code on a machine which has unsigned long defined as 8 bytes, the buggy code here will mark the second branch as duplicate branch since on x86-64 bit machines, unsigned long and unsigned long long have the same size, ie, 8 bytes.

                  case sizeof(unsigned long):
                    c = 'l';
                    break;

#if defined(CONFIG_HAVE_LONG_LONG) && ULLONG_MAX != ULONG_MAX
                  case sizeof(unsigned long long):
                    c = 'l';
                    flags |= FL_LONG;
                    flags &= ~FL_SHORT;
                    break;
#endif

A relatively simple fix would be to have the case for unsigned long in the #else branch of the #if.

#if defined(CONFIG_HAVE_LONG_LONG) && ULLONG_MAX != ULONG_MAX
                  case sizeof(unsigned long long):
                    c = 'l';
                    flags |= FL_LONG;
                    flags &= ~FL_SHORT;
                    break;
#else
  case sizeof(unsigned long):
                    c = 'l';
                    break;
#endif

This should fix the issue of duplicate branch.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions