Skip to content

Infinite Loop in cfIEEE1284NormalizeMakeModel used with device_id on empty MFG and MDL #214

Description

@belayaav

I've discovered this issue while has been testing GHSA-rcq7-rv5g-j3r4

According to note in ieee1284.c we can give deviceID on input of cfIEEE1284NormalizeMakeModel:

 cfIEEE1284NormalizeMakeModel(
 640     const char *make_and_model,         // I - Original make-and-model string
 641                                         //     or device ID

So I've tried it to understand how it works and discovered that if cfIEEE1284NormalizeMakeModel receives the line with empty MFG and MDL on input, it goes to infinite loop. It reproduces even if line has other not empty values, like CMD. My examples are:

"MFG:;MDL:;"
"MFG:;MDL:;CMD:PostScript;"

Loop doesn't reproduce with line:

"MDL:;"

Both MFG and MDL values should be empty.

I cannot assess a severity of this issue, as I cannot fully understand if using cfIEEE1284NormalizeMakeModel with deviceID is life-case scenario, so advice is appreciated.

Steps to reproduce:

  1. I've defined function as:
static int
run_device_id_case(const char *device_id)
{
  char output[OUTPUT_SIZE];
  char *result;

  memset(output, 0, sizeof(output));

  result = cfIEEE1284NormalizeMakeModel(
      device_id,                       
      NULL,                            
      CF_IEEE1284_NORMALIZE_HUMAN,
      NULL,
      output,
      sizeof(output),
      NULL,
      NULL,
      NULL);

  if (result == NULL)
    printf("    Result: NULL\n");
  else
    printf("    Result: \"%s\"\n", result);

  fflush(stdout);
  return 0;
}
  1. Input data:
static const test_case_t tests[] =
  {
    {
      "Corrupted device_id",
      TEST_DEVICE_ID,
      "MFG:;MDL:;"
    },
  1. Run test

Result: Function hanged

Expected result: Corrupted data was filtered or function exits with error code

I can attach my script if it'll help to reproduce.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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