@Override
	public int getLength(MemBuffer buf, int maxLength) {
		try {
			if (!checkMagic(buf, MAGIC_AIFF) && !checkMagic(buf, MAGIC_AIFC)) {
				return -1;
			}

			int dataSize = buf.getInt(4);
			if (dataSize <= 0) {
				// check dataSize for validity.  TODO: more strict with upper bounds
				return -1;
			}

			return dataSize + 8;
		}
		catch (Exception e) {
			Msg.debug(this, "Invalid AIFF data at " + buf.getAddress());
		}
		return -1;
	}
Byte search mask for magic bytes
Ghidra/Framework/SoftwareModeling/src/main/java/ghidra/program/model/data/AIFFDataType.java