Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Buggy handling of unsigned long in vsprintf_internal #270

Open
PwnVerse opened this issue Oct 18, 2023 · 1 comment
Open

Buggy handling of unsigned long in vsprintf_internal #270

PwnVerse opened this issue Oct 18, 2023 · 1 comment

Comments

@PwnVerse
Copy link

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.

@davids5
Copy link
Member

davids5 commented Oct 19, 2023

@PwnVerse Please submit a PR upstream.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants