Note: Although Firefox >= 57 has a native implementation, the maximum message size can be reset for all data channels at a later stage. See: https://bugzilla.mozilla.org/show_bug.cgi?id=1426831
768418
function wrapDcSend(dc, pc) {
      var origDataChannelSend = dc.send;
      dc.send = function() {
        var data = arguments[0];
        var length = data.length || data.size || data.byteLength;
        if (dc.readyState === 'open' &&
            pc.sctp && length > pc.sctp.maxMessageSize) {
          throw new TypeError('Message too large (can send a maximum of ' +
            pc.sctp.maxMessageSize + ' bytes)');
        }
        return origDataChannelSend.apply(dc, arguments);
      };
    }
262736
def size_limit_exceeded?
      if @max_bytes
        # note that Dir.glob ignores hidden directories (e.g. ".git") so the
        # size total correctly excludes those hidden contents that are not to
        # be uploaded after scrape. this may cause the on-disk directory size
        # to far exceed the upload size.
        globbie = ::File.join(@repo_dir, '**/*')
        size = 0
        ::Dir.glob(globbie) do |f|
          size += ::File.stat(f).size rescue 0 if ::File.file?(f)
          break if size > @max_bytes
        end
        size > @max_bytes
      else
        false
      end
    end
737468
function(message, signaling_key) {
        if (signaling_key.byteLength != 52) {
            throw new Error("Got invalid length signaling_key");
        }
        if (message.byteLength < 1 + 16 + 10) {
            throw new Error("Got invalid length message");
        }
        if (message[0] != 1) {
            throw new Error("Got bad version number: " + message[0]);
        }
        var aes_key = signaling_key.slice(0, 32);
        var mac_key = signaling_key.slice(32, 32 + 20);
        var iv = message.slice(1, 17);
        var ciphertext = message.slice(1 + 16, message.byteLength - 10);
        var ivAndCiphertext = message.slice(0, message.byteLength - 10);
        var mac = message.slice(message.byteLength - 10, message.byteLength);
        libsignal.crypto.verifyMAC(ivAndCiphertext, mac_key, mac, 10);
        return libsignal.crypto.decrypt(aes_key, ciphertext, iv);
    }
980492
@Override
    @Deprecated
    public int getMaxMessagesPerRead() {
        try {
            MaxMessagesRecvByteBufAllocator allocator = getRecvByteBufAllocator();
            return allocator.maxMessagesPerRead();
        } catch (ClassCastException e) {
            throw new IllegalStateException("getRecvByteBufAllocator() must return an object of type " +
                    "MaxMessagesRecvByteBufAllocator", e);
        }
    }
803161
private static int getWebSocketContentLength(HttpMessage message) {
        // WebSocket messages have constant content-lengths.
        HttpHeaders h = message.headers();
        if (message instanceof HttpRequest) {
            HttpRequest req = (HttpRequest) message;
            if (HttpMethod.GET.equals(req.method()) &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_KEY1) &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_KEY2)) {
                return 8;
            }
        } else if (message instanceof HttpResponse) {
            HttpResponse res = (HttpResponse) message;
            if (res.status().code() == 101 &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_ORIGIN) &&
                    h.contains(HttpHeaderNames.SEC_WEBSOCKET_LOCATION)) {
                return 16;
            }
        }

        // Not a web socket message
        return -1;
    }
480690
private boolean
toWire(DNSOutput out, int maxLength) {
	if (maxLength < Header.LENGTH)
		return false;

	Header newheader = null;

	int tempMaxLength = maxLength;
	if (tsigkey != null)
		tempMaxLength -= tsigkey.recordLength();

	OPTRecord opt = getOPT();
	byte [] optBytes = null;
        if (opt != null) {
		optBytes = opt.toWire(Section.ADDITIONAL);
		tempMaxLength -= optBytes.length;
	}

	int startpos = out.current();
	header.toWire(out);
	Compression c = new Compression();
	int flags = header.getFlagsByte();
	int additionalCount = 0;
	for (int i = 0; i < 4; i++) {
		int skipped;
		if (sections[i] == null)
			continue;
		skipped = sectionToWire(out, i, c, tempMaxLength);
		if (skipped != 0 && i != Section.ADDITIONAL) {
			flags = Header.setFlag(flags, Flags.TC, true);
			out.writeU16At(header.getCount(i) - skipped,
				       startpos + 4 + 2 * i);
			for (int j = i + 1; j < Section.ADDITIONAL; j++)
				out.writeU16At(0, startpos + 4 + 2 * j);
			break;
		}
		if (i == Section.ADDITIONAL)
			additionalCount = header.getCount(i) - skipped;
	}

	if (optBytes != null) {
		out.writeByteArray(optBytes);
		additionalCount++;
	}

	if (flags != header.getFlagsByte())
		out.writeU16At(flags, startpos + 2);

	if (additionalCount != header.getCount(Section.ADDITIONAL))
		out.writeU16At(additionalCount, startpos + 10);

	if (tsigkey != null) {
		TSIGRecord tsigrec = tsigkey.generate(this, out.toByteArray(),
						      tsigerror, querytsig);

		tsigrec.toWire(out, Section.ADDITIONAL, c);
		out.writeU16At(additionalCount + 1, startpos + 10);
	}

	return true;
}
1067095
public void verifyMessageSize(int maxMessageSize) {
       Iterator<MessageAndOffset> shallowIter =  internalIterator(true);
       while(shallowIter.hasNext()) {
           MessageAndOffset messageAndOffset = shallowIter.next();
           int payloadSize = messageAndOffset.message.payloadSize();
           if(payloadSize > maxMessageSize) {
               throw new MessageSizeTooLargeException("payload size of " + payloadSize + " larger than " + maxMessageSize);
           }
       }
    }
329411
public static String ENDPOINT_MAX_MESSAGE_SIZE_TOO_LONG(Object arg0, Object arg1, Object arg2, Object arg3) {
        return localizer.localize(localizableENDPOINT_MAX_MESSAGE_SIZE_TOO_LONG(arg0, arg1, arg2, arg3));
    }
891532
private void setMaxMessageSize(Method method, EndpointMethodHelper endpointMethodHelper) {
        OnMessage onMsgAnnotation = method.getAnnotation(OnMessage.class);
        Long maxMessageSize = onMsgAnnotation.maxMessageSize();
        // maxMessageSize is -1 if it is not defined.
        if (maxMessageSize < -1) {
            // user has put in an invalid value, so change it to undefined.
            maxMessageSize = Constants.ANNOTATED_UNDEFINED_MAX_MSG_SIZE;
        }

        endpointMethodHelper.getMethodData().setMaxMessageSize(maxMessageSize);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "setMaxMessageSize: maxMessageSize from annotation: " + maxMessageSize);
        }
    }
426464
def max_recv_data_size(self):
        
        with self.lock:
            if self.device is None:
                raise IOError(errno.ENODEV, os.strerror(errno.ENODEV))
            else:
                return self.device.get_max_recv_data_size(self.target)
1360275
def _ensure_valid_record_size(self, size):
        """"""
        if size > self.config['max_request_size']:
            raise Errors.MessageSizeTooLargeError(
                "The message is %d bytes when serialized which is larger than"
                " the maximum request size you have configured with the"
                " max_request_size configuration" % (size,))
        if size > self.config['buffer_memory']:
            raise Errors.MessageSizeTooLargeError(
                "The message is %d bytes when serialized which is larger than"
                " the total memory buffer you have configured with the"
                " buffer_memory configuration." % (size,))
765677
static function maxLogSize()
    {
        if ( isset( $GLOBALS['eZDebugMaxLogSize'] ) )
        {
            return $GLOBALS['eZDebugMaxLogSize'];
        }
        else if ( defined( 'EZPUBLISH_LOG_MAX_FILE_SIZE' ) )
        {
            self::setMaxLogSize( (int)EZPUBLISH_LOG_MAX_FILE_SIZE );
            return (int)EZPUBLISH_LOG_MAX_FILE_SIZE;
        }
        return self::MAX_LOGFILE_SIZE;
    }
507196
function ruleMax($max, $error_message = null) {
        if (!is_numeric($max)) {
            throw new \Exception('Incorrect parameter MAX in rule max');
        }

        return $this->_rule('max:' . $max, $error_message);
    }
139539
long parseMaxLogSize (String maxLogSizeStr) {
		long maxLogSize = SizeRollingFileHandler.DEFAULT_LOG_SIZE_BOUND;

		if (maxLogSizeStr != null) {
			maxLogSizeStr = maxLogSizeStr.trim ().toUpperCase ();
			
			if (maxLogSizeStr.endsWith ("T")) {
				maxLogSizeStr = maxLogSizeStr.substring (0, maxLogSizeStr.length () - 1);
				try {
					maxLogSize = Long.parseLong (maxLogSizeStr) * 1024L * 1024L * 1024L * 1024L;
				} catch (NumberFormatException ex) {
					LogHelperDebug.printError ("Could not parse a long in " + maxLogSizeStr, ex, false);
				}
			} else if (maxLogSizeStr.endsWith ("G")) {
				maxLogSizeStr = maxLogSizeStr.substring (0, maxLogSizeStr.length () - 1);
				try {
					maxLogSize = Long.parseLong (maxLogSizeStr) * 1024L * 1024L * 1024L;
				} catch (NumberFormatException ex) {
					LogHelperDebug.printError ("Could not parse a long in " + maxLogSizeStr, ex, false);
				}
			} else if (maxLogSizeStr.endsWith ("M")) {
				maxLogSizeStr = maxLogSizeStr.substring (0, maxLogSizeStr.length () - 1);
				try {
					maxLogSize = Long.parseLong (maxLogSizeStr) * 1024L * 1024L;
				} catch (NumberFormatException ex) {
					LogHelperDebug.printError ("Could not parse a long in " + maxLogSizeStr, ex, false);
				}
			} else if (maxLogSizeStr.endsWith ("K")) {
				maxLogSizeStr = maxLogSizeStr.substring (0, maxLogSizeStr.length () - 1);
				try {
					maxLogSize = Long.parseLong (maxLogSizeStr) * 1024L;
				} catch (NumberFormatException ex) {
					LogHelperDebug.printError ("Could not parse a long in " + maxLogSizeStr, ex, false);
				}
			} else {
				try {
					maxLogSize = Long.parseLong (maxLogSizeStr);
				} catch (NumberFormatException ex) {
					LogHelperDebug.printError ("Could not parse a long in " + maxLogSizeStr, ex, false);
				}
			}
		}
		return maxLogSize;
	}
459504
static int mergeDelimitedFrom(DataInput in, Object message, Schema schema, 
            boolean decodeNestedMessageAsGroup) throws IOException
    {
        final byte size = in.readByte();
        final int len = 0 == (size & 0x80) ? size : CodedInput.readRawVarint32(in, size);
        
        if(len < 0)
            throw ProtobufException.negativeSize();
        
        if(len != 0)
        {
            // not an empty message
            if(len > CodedInput.DEFAULT_BUFFER_SIZE && in instanceof InputStream)
            {
                // message too big
                final CodedInput input = new CodedInput(new LimitedInputStream((InputStream)in, len), 
                        decodeNestedMessageAsGroup);
                schema.mergeFrom(input, message);
                input.checkLastTagWas(0);
            }
            else
            {
                final byte[] buf = new byte[len];
                in.readFully(buf, 0, len);
                final ByteArrayInput input = new ByteArrayInput(buf, 0, len, 
                        decodeNestedMessageAsGroup);
                try
                {
                    schema.mergeFrom(input, message);
                }
                catch(ArrayIndexOutOfBoundsException e)
                {
                    throw ProtobufException.truncatedMessage(e);
                }
                input.checkLastTagWas(0);
            }
        }

        // check it since this message is embedded in the DataInput.
        if(!schema.isInitialized(message))
            throw new UninitializedMessageException(message, schema);
        
        return len;
    }
413008
def _VarUInt64ByteSizeNoTag(uint64):
  
  if uint64 <= 0x7f: return 1
  if uint64 <= 0x3fff: return 2
  if uint64 <= 0x1fffff: return 3
  if uint64 <= 0xfffffff: return 4
  if uint64 <= 0x7ffffffff: return 5
  if uint64 <= 0x3ffffffffff: return 6
  if uint64 <= 0x1ffffffffffff: return 7
  if uint64 <= 0xffffffffffffff: return 8
  if uint64 <= 0x7fffffffffffffff: return 9
  if uint64 > UINT64_MAX:
    raise message.EncodeError('Value out of range: %d' % uint64)
  return 10
407481
private static int maxOutputBufferLength(int inputLength) {
        double factor;
        if (inputLength < 200) {
            factor = 1.5;
        } else if (inputLength < 500) {
            factor = 1.2;
        } else if (inputLength < 1000) {
            factor = 1.1;
        } else if (inputLength < 10000) {
            factor = 1.05;
        } else {
            factor = 1.02;
        }
        return 13 + (int) (inputLength * factor);
    }