--- a/core/bug_api.php	2016-10-15 19:24:54.339654674 -0500
+++ b/core/bug_api.php	2016-10-15 19:25:37.379558438 -0500
@@ -830,6 +830,16 @@
 
 	$c_bug_id = (int)$p_bug_id;
 
+	// Prevent very large bug IDs from causing database errors
+	if( $c_bug_id > (2**31) - 1 ) {
+		if( $p_trigger_errors ) {
+			error_parameters( $p_bug_id );
+			trigger_error( ERROR_BUG_NOT_FOUND, ERROR );
+		} else {
+			return false;
+		}
+	}
+
 	db_param_push();
 	$t_query = 'SELECT * FROM {bug} WHERE id=' . db_param();
 	$t_result = db_query( $t_query, array( $c_bug_id ) );
@@ -2176,4 +2186,4 @@
 		}
 	}
 	return $p_new_status;
-}
\ No newline at end of file
+}
--- a/core/bugnote_api.php	2016-10-15 19:25:00.727640390 -0500
+++ b/core/bugnote_api.php	2016-10-15 19:25:48.575533396 -0500
@@ -128,6 +128,11 @@
  * @access public
  */
 function bugnote_exists( $p_bugnote_id ) {
+	// Prevent very large bugnote IDs from causing database errors
+	if( (int)$p_bugnote_id > (2**31) - 1 ) {
+		return false;
+	}
+
 	db_param_push();
 	$t_query = 'SELECT COUNT(*) FROM {bugnote} WHERE id=' . db_param();
 	$t_result = db_query( $t_query, array( $p_bugnote_id ) );