Skip to content

Prefetch Plugin Overflows when adding greater than 32-bit numbers #8569

@mikeV02

Description

@mikeV02

Hello,

I was configuring the prefetch plugin to use for HLS caching hit improvements, and captured the required patterns with regex and added the next segments to download according to matches on our HLS manifest files. However, one of these patters, uses numbering higher than the max signed 32-bit integer, thus I saw it was overflowing and wrapping back into the negative integers. Looking at the code, I see the overflow occurs on the function "evaluate" of the plugins/prefetch/plugin.cc file. Specifically on the following segment of code:

if (String::npos == pos) {
    result = getValue(stmt);
  } else {
    unsigned a = getValue(stmt.substr(0, pos));
    unsigned b = getValue(stmt.substr(pos + 1));

    if ('+' == stmt[pos]) {
      result = a + b;
    } else {
      result = a - b;
    }
  }

  std::ostringstream convert;
  convert << std::setw(len) << std::setfill('0') << result;
  PrefetchDebug("evaluation of '%s' resulted in '%s'", v.c_str(), convert.str().c_str());
  return convert.str();

For example, I am trying to add 2207264608520000 + 60060000. I tried striping the four 0s at the end from the pattern, but the resulting number is still greater than the max signed 32-bit integer.

I will try recompiling using long instead of int for the result, a and b variables, but I am not sure if the getValue function may impact as well.

Note: I am running 64-bit Debian 11

Sincerely!

Mike

Metadata

Metadata

Assignees

Labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions