aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGravatar Vitaly Takmazov2022-12-14 20:00:38 +0300
committerGravatar Vitaly Takmazov2022-12-14 20:10:15 +0300
commit708c1fea2e47997698c493e13cd16c200d60d276 (patch)
treeca276ea2526c9ecf5f029b921ad0843659982b69 /src
parent560d89cb0285435f0e7c640b3fb67ab1197df808 (diff)
Fix the integer overflow issue
Diffstat (limited to 'src')
-rw-r--r--src/main/java/com/juick/service/MessagesServiceImpl.java4
-rw-r--r--src/test/java/com/juick/server/tests/ServerTests.java9
2 files changed, 11 insertions, 2 deletions
diff --git a/src/main/java/com/juick/service/MessagesServiceImpl.java b/src/main/java/com/juick/service/MessagesServiceImpl.java
index c5037c31..5969443c 100644
--- a/src/main/java/com/juick/service/MessagesServiceImpl.java
+++ b/src/main/java/com/juick/service/MessagesServiceImpl.java
@@ -817,11 +817,11 @@ public class MessagesServiceImpl extends BaseJdbcService implements MessagesServ
+ "ON banned.reply_id = replies.replyto AND replies.reply_id != replies.replyto AND banned.message_id=replies.message_id "
+ "WHERE replies.message_id IN (:ids)) " + "SELECT messages.message_id, 0 as rid, 0 as replyto, "
+ "messages.user_id,users.nick, 0 as usr_banned, " + "messages.ts,"
- + "messages.readonly,messages.privacy, messages.replies-COUNT(DISTINCT banned.reply_id) as replies,"
+ + "messages.readonly,messages.privacy, 1.*messages.replies-COUNT(DISTINCT banned.reply_id) as replies,"
+ "messages.attach,COUNT(DISTINCT favorites.user_id) AS likes,messages.hidden,"
+ "'' as tags, messages_txt.repliesby, messages_txt.txt, '' as q, "
+ "messages.updated, 0 as to_uid, NULL as to_name, messages_txt.updated_at, '' as m_user_uri, "
- + "'' as to_uri, '' as msg_reply_uri, 0 as html, (messages.replies - subscr_messages.last_read_rid) > 0 as unread "
+ + "'' as to_uri, '' as msg_reply_uri, 0 as html, (1.*messages.replies - subscr_messages.last_read_rid) > 0 as unread "
+ "FROM (messages INNER JOIN messages_txt " + "ON messages.message_id=messages_txt.message_id) "
+ "INNER JOIN users ON messages.user_id=users.id " + "LEFT JOIN subscr_messages "
+ "ON messages.message_id=subscr_messages.message_id AND subscr_messages.suser_id=:uid "
diff --git a/src/test/java/com/juick/server/tests/ServerTests.java b/src/test/java/com/juick/server/tests/ServerTests.java
index 3a7697e1..d964185d 100644
--- a/src/test/java/com/juick/server/tests/ServerTests.java
+++ b/src/test/java/com/juick/server/tests/ServerTests.java
@@ -2743,4 +2743,13 @@ public class ServerTests {
mockMvc.perform(get(htmlUri).accept(Context.LD_JSON_MEDIA_TYPE)).andExpect(status().is3xxRedirection())
.andExpect(redirectedUrl(ldUri));
}
+ @Test
+ @Transactional
+ public void unsignedOverlowTest() throws Exception {
+ var result = commandsManager.processCommand(ugnich, "test", emptyUri);
+ var mid = result.getNewMessage().get().getMid();
+ jdbcTemplate.update("UPDATE subscr_messages SET last_read_rid=10 WHERE message_id=?", mid);
+ assertThat(messagesService.getMessages(ugnich, List.of(mid)).size(), is(1));
+ assertThat(messagesService.getMessages(ugnich, List.of(mid)).get(0).isUnread(), is(false));
+ }
}