sscanf change prevents build of CURRENT

From: John F Carr <jfc_at_mit.edu>
Date: Wed, 30 Aug 2023 18:34:00 UTC
I had a problem yesterday and today rebuilding a -CURRENT system from source:

  --- magic.mgc ---
  ./mkmagic magic
  magic, 4979: Warning: Current entry does not yet have a description for adding a MIME type
  mkmagic: could not find any valid magic files!

The cause was an sscanf call unexpectedly failing to parse the input.  This caused
the mkmagic program (internal tool used to build magic number table for file) to fail.

If I link mkmagic against the static libc.a in /usr/obj then it works.  So my installed
libc.so is broken and the latest source works.  I think.  My installed kernel is at
76edfabbecde, the end of the binary integer parsing commit series, so my libc
should be the same.

The program below demonstrates the bug.  See src/contrib/file/src for context.

I am trying to manually compile a working mkmagic and restart the build to get unstuck.

#include <stdio.h>
#include <stdint.h>

struct guid {
	uint32_t data1;
	uint16_t data2;
	uint16_t data3;
	uint8_t data4[8];
};

int main(int argc, char *argv[])
{
  struct guid g = {0, 0, 0, {0}};
  char *text = "75B22630-668E-11CF-A6D9-00AA0062CE6C";

  if (argc > 1)
    text = argv[1];
  int count =
    sscanf(text,
           "%8x-%4hx-%4hx-%2hhx%2hhx-%2hhx%2hhx%2hhx%2hhx%2hhx%2hhx",
           &g.data1, &g.data2, &g.data3, &g.data4[0], &g.data4[1],
           &g.data4[2], &g.data4[3], &g.data4[4], &g.data4[5],
           &g.data4[6], &g.data4[7]);

  fprintf(stdout,
          "[%d]:\n%08x-%04hx-%04hx-%02hhx%02hhx-%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx\n",
          count,
          g.data1, g.data2, g.data3, g.data4[0], g.data4[1],
          g.data4[2], g.data4[3], g.data4[4], g.data4[5],
          g.data4[6], g.data4[7]);
  return count != 11;
}