MuntashirAkon/AppManager · error

Error! Buffer overflow on exec_jar_path.\n

Error message

Error! Buffer overflow on exec_jar_path.\n

What it means

Guard after snprintf in main(): formatting TMP_PATH plus the am.jar file name into the 512-byte exec_jar_path buffer exceeded its size, so the resulting path would have been truncated or overrun. Typically fired when the supplied am_jar_name argument is unusually long; the process exits rather than exec'ing a corrupted path.

Source

Thrown at app/src/main/cpp/run_server.c:106

    // Validate Paths
    if (!is_safe_string(am_jar_name) || !is_safe_string(main_jar_name) || !is_safe_string(app_id) ||
        !is_safe_string(user_id)) {
        fprintf(stderr, "Error! Invalid characters in arguments.\n");
        return 1;
    }

    // Validate debug and bgrun
    if ((strcmp(debug, "0") != 0 && strcmp(debug, "1") != 0)) {
        fprintf(stderr, "Error! debug must be either 0 or 1.\n");
        return 1;
    }

    // /data/local/tmp/am.jar
    char exec_jar_path[512];
    if (snprintf(exec_jar_path, sizeof(exec_jar_path), "%s/%s", TMP_PATH, am_jar_name) >=
        sizeof(exec_jar_path)) {
        fprintf(stderr, "Error! Buffer overflow on exec_jar_path.\n");
        return 1;
    }

    // /data/local/tmp/main.jar
    char main_jar_path[512];
    if (snprintf(main_jar_path, sizeof(main_jar_path), "%s/%s", TMP_PATH, main_jar_name) >=
        sizeof(main_jar_path)) {
        fprintf(stderr, "Error! Buffer overflow on main_jar_path.\n");
        return 1;
    }

    // Prioritized list of fallback source paths
    char am_jar_fallbacks[4][512];
    snprintf(am_jar_fallbacks[0], sizeof(am_jar_fallbacks[0]), "/sdcard/Android/data/%s/cache/%s",
             app_id,
             am_jar_name);
    snprintf(am_jar_fallbacks[1], sizeof(am_jar_fallbacks[1]),
             "/storage/emulated/%s/Android/data/%s/cache/%s",

View on GitHub (pinned to 0152f468fc)

Solutions

  1. Shorten am_jar_name on the caller side (keep filenames well under 400 characters)
  2. Increase the buffer size (e.g. char exec_jar_path[1024] or PATH_MAX) in run_server.c and rebuild
  3. Validate filename length in app code before exec

Example fix

// before
char exec_jar_path[512];
// after
char exec_jar_path[PATH_MAX];
Defensive patterns

Strategy: validation

Validate before calling

String path = TMP_PATH + "/" + amJarName;
if (path.length() >= 512)
    throw new IllegalArgumentException("am_jar_name too long (path would exceed 512 bytes)");

Prevention

When it happens

Trigger: TMP_PATH plus "/" plus am_jar_name totals 512 or more bytes, i.e. am_jar_name alone is longer than roughly 512 minus len(TMP_PATH) - 1 characters.

Common situations: Extremely long generated or hashed jar filenames; nested subdirectories smuggled into am_jar_name; TMP_PATH reconfigured to a long custom path.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


AI-assisted analysis of MuntashirAkon/AppManager@0152f468fc (2026-09-12). Data as JSON: /api/errors/3eaeff626fe33bec. Report an issue: GitHub.