NationalSecurityAgency/ghidra · error

Max ascii string size is %d you provided: %lu chars. Exiting

Error message

Max ascii string size is %d you provided: %lu chars. Exiting.\n

What it means

gdis validation error in argument mode. The supplied ascii byte-string length exceeds BYTE_BUFFER_SIZE*2 (two hex chars per byte). The program prints the limit and the actual length then calls exit(-1), terminating the process immediately.

Source

Thrown at GPL/GnuDisassembler/src/gdis/c/disasm_1.c:366

				}
				else {
					//no "*" in the string, so no disassembly options
					//replace newline with null terminator
					strncpy(byteStringBuffer, bytesAndOptionsBuffer, sizeof(byteStringBuffer));
					p = strchr(byteStringBuffer,'\n');
					if (p){
						*p = '\0';
					}
				}
			}
			else {
				fprintf(stderr, "exiting, no ASCII hex found\n");
				return 0; // finished! #TODO
			}
		}
		else {
			if(strlen(byteString) > BYTE_BUFFER_SIZE*2) {
				fprintf(stderr, "Max ascii string size is %d you provided: %lu chars. Exiting.\n", BYTE_BUFFER_SIZE*2,
						strlen(byteString));
				exit(-1);
			}
			strncpy(byteStringBuffer, byteString, BYTE_BUFFER_SIZE*2);
			stdin_mode = 0; // break out of the while loop
		}

		int size = strlen(byteStringBuffer);
		if((size % 2) != 0){
			fprintf(stderr, "need even-number of ascii chars for byte-stream: (offset: %08lx, %s, %ld)\n", offset, byteStringBuffer, strlen(byteStringBuffer));
			exit(-1);
		}

		memset(byteBuffer, 0x00, BYTE_BUFFER_SIZE);

		//
		// TODO:
		// check to make sure chars are only valid HEX.

View on GitHub (pinned to d5f144c24d)

Solutions

  1. Shorten the byte-string to at most BYTE_BUFFER_SIZE*2 hex characters.
  2. Increase BYTE_BUFFER_SIZE in the source and rebuild if a larger region is legitimately needed.
  3. Split the input into chunks and invoke gdis once per chunk.
  4. Switch to stdin mode which reads into bytesAndOptionsBuffer of related size if that fits better.

Example fix

// before (constant too small for the input)
#define BYTE_BUFFER_SIZE 256   // allows 512 hex chars; user passes 600

// after
#define BYTE_BUFFER_SIZE 512    // allows 1024 hex chars
// (rebuild gdis)
Defensive patterns

Strategy: validation

Validate before calling

size_t n = strlen(byteString);
if (n > BYTE_BUFFER_SIZE * 2) {
  fprintf(stderr, "byte string too long (%zu > %d)\n", n, BYTE_BUFFER_SIZE*2);
  return 2;
}

Prevention

When it happens

Trigger: Passing a byte-string (argv[7]) longer than BYTE_BUFFER_SIZE*2 characters in non-stdin mode.

Common situations: Disassembling a very large code region in one shot; wrong buffer-size constant; a script concatenating many hex strings without truncation.

Related errors


AI-assisted analysis of NationalSecurityAgency/ghidra@d5f144c24d (2026-08-14). Data as JSON: /api/errors/bc74bc2e23df792f. Report an issue: GitHub.