Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
briar
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
675
Issues
675
List
Boards
Labels
Service Desk
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
briar
briar
Commits
d95a5fd5
Verified
Commit
d95a5fd5
authored
May 17, 2018
by
akwizgran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use lower default limit for BDF strings and raws.
parent
ed2c0336
Pipeline
#1544
passed with stage
in 8 minutes and 20 seconds
Changes
7
Pipelines
1
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
191 additions
and
100 deletions
+191
-100
bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfReader.java
...ain/java/org/briarproject/bramble/api/data/BdfReader.java
+3
-2
bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfReaderFactory.java
...a/org/briarproject/bramble/api/data/BdfReaderFactory.java
+2
-1
bramble-core/src/main/java/org/briarproject/bramble/data/BdfReaderFactoryImpl.java
...a/org/briarproject/bramble/data/BdfReaderFactoryImpl.java
+6
-3
bramble-core/src/main/java/org/briarproject/bramble/data/BdfReaderImpl.java
...ain/java/org/briarproject/bramble/data/BdfReaderImpl.java
+10
-9
bramble-core/src/main/java/org/briarproject/bramble/data/MetadataParserImpl.java
...ava/org/briarproject/bramble/data/MetadataParserImpl.java
+2
-2
bramble-core/src/test/java/org/briarproject/bramble/data/BdfReaderImplTest.java
...java/org/briarproject/bramble/data/BdfReaderImplTest.java
+166
-81
briar-core/src/main/java/org/briarproject/briar/messaging/MessagingModule.java
...ava/org/briarproject/briar/messaging/MessagingModule.java
+2
-2
No files found.
bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfReader.java
View file @
d95a5fd5
...
...
@@ -8,6 +8,7 @@ import java.io.IOException;
public
interface
BdfReader
{
int
DEFAULT_NESTED_LIMIT
=
5
;
int
DEFAULT_MAX_BUFFER_SIZE
=
64
*
1024
;
boolean
eof
()
throws
IOException
;
...
...
@@ -39,13 +40,13 @@ public interface BdfReader {
boolean
hasString
()
throws
IOException
;
String
readString
(
int
maxLength
)
throws
IOException
;
String
readString
()
throws
IOException
;
void
skipString
()
throws
IOException
;
boolean
hasRaw
()
throws
IOException
;
byte
[]
readRaw
(
int
maxLength
)
throws
IOException
;
byte
[]
readRaw
()
throws
IOException
;
void
skipRaw
()
throws
IOException
;
...
...
bramble-api/src/main/java/org/briarproject/bramble/api/data/BdfReaderFactory.java
View file @
d95a5fd5
...
...
@@ -9,5 +9,6 @@ public interface BdfReaderFactory {
BdfReader
createReader
(
InputStream
in
);
BdfReader
createReader
(
InputStream
in
,
int
nestedLimit
);
BdfReader
createReader
(
InputStream
in
,
int
nestedLimit
,
int
maxBufferSize
);
}
bramble-core/src/main/java/org/briarproject/bramble/data/BdfReaderFactoryImpl.java
View file @
d95a5fd5
...
...
@@ -8,6 +8,7 @@ import java.io.InputStream;
import
javax.annotation.concurrent.Immutable
;
import
static
org
.
briarproject
.
bramble
.
api
.
data
.
BdfReader
.
DEFAULT_MAX_BUFFER_SIZE
;
import
static
org
.
briarproject
.
bramble
.
api
.
data
.
BdfReader
.
DEFAULT_NESTED_LIMIT
;
@Immutable
...
...
@@ -16,11 +17,13 @@ class BdfReaderFactoryImpl implements BdfReaderFactory {
@Override
public
BdfReader
createReader
(
InputStream
in
)
{
return
new
BdfReaderImpl
(
in
,
DEFAULT_NESTED_LIMIT
);
return
new
BdfReaderImpl
(
in
,
DEFAULT_NESTED_LIMIT
,
DEFAULT_MAX_BUFFER_SIZE
);
}
@Override
public
BdfReader
createReader
(
InputStream
in
,
int
nestedLimit
)
{
return
new
BdfReaderImpl
(
in
,
nestedLimit
);
public
BdfReader
createReader
(
InputStream
in
,
int
nestedLimit
,
int
maxBufferSize
)
{
return
new
BdfReaderImpl
(
in
,
nestedLimit
,
maxBufferSize
);
}
}
bramble-core/src/main/java/org/briarproject/bramble/data/BdfReaderImpl.java
View file @
d95a5fd5
...
...
@@ -37,15 +37,16 @@ class BdfReaderImpl implements BdfReader {
private
static
final
byte
[]
EMPTY_BUFFER
=
new
byte
[
0
];
private
final
InputStream
in
;
private
final
int
nestedLimit
;
private
final
int
nestedLimit
,
maxBufferSize
;
private
boolean
hasLookahead
=
false
,
eof
=
false
;
private
byte
next
;
private
byte
[]
buf
=
new
byte
[
8
];
BdfReaderImpl
(
InputStream
in
,
int
nestedLimit
)
{
BdfReaderImpl
(
InputStream
in
,
int
nestedLimit
,
int
maxBufferSize
)
{
this
.
in
=
in
;
this
.
nestedLimit
=
nestedLimit
;
this
.
maxBufferSize
=
maxBufferSize
;
}
private
void
readLookahead
()
throws
IOException
{
...
...
@@ -91,8 +92,8 @@ class BdfReaderImpl implements BdfReader {
if
(
hasBoolean
())
return
readBoolean
();
if
(
hasLong
())
return
readLong
();
if
(
hasDouble
())
return
readDouble
();
if
(
hasString
())
return
readString
(
Integer
.
MAX_VALUE
);
if
(
hasRaw
())
return
readRaw
(
Integer
.
MAX_VALUE
);
if
(
hasString
())
return
readString
();
if
(
hasRaw
())
return
readRaw
();
if
(
hasList
())
return
readList
(
level
);
if
(
hasDictionary
())
return
readDictionary
(
level
);
throw
new
FormatException
();
...
...
@@ -245,11 +246,11 @@ class BdfReaderImpl implements BdfReader {
}
@Override
public
String
readString
(
int
maxLength
)
throws
IOException
{
public
String
readString
()
throws
IOException
{
if
(!
hasString
())
throw
new
FormatException
();
hasLookahead
=
false
;
int
length
=
readStringLength
();
if
(
length
<
0
||
length
>
max
Length
)
throw
new
FormatException
();
if
(
length
<
0
||
length
>
max
BufferSize
)
throw
new
FormatException
();
if
(
length
==
0
)
return
""
;
readIntoBuffer
(
length
);
return
new
String
(
buf
,
0
,
length
,
"UTF-8"
);
...
...
@@ -279,11 +280,11 @@ class BdfReaderImpl implements BdfReader {
}
@Override
public
byte
[]
readRaw
(
int
maxLength
)
throws
IOException
{
public
byte
[]
readRaw
()
throws
IOException
{
if
(!
hasRaw
())
throw
new
FormatException
();
hasLookahead
=
false
;
int
length
=
readRawLength
();
if
(
length
<
0
||
length
>
max
Length
)
throw
new
FormatException
();
if
(
length
<
0
||
length
>
max
BufferSize
)
throw
new
FormatException
();
if
(
length
==
0
)
return
EMPTY_BUFFER
;
byte
[]
b
=
new
byte
[
length
];
readIntoBuffer
(
b
,
length
);
...
...
@@ -381,7 +382,7 @@ class BdfReaderImpl implements BdfReader {
BdfDictionary
dictionary
=
new
BdfDictionary
();
readDictionaryStart
();
while
(!
hasDictionaryEnd
())
dictionary
.
put
(
readString
(
Integer
.
MAX_VALUE
),
readObject
(
level
+
1
));
dictionary
.
put
(
readString
(),
readObject
(
level
+
1
));
readDictionaryEnd
();
return
dictionary
;
}
...
...
bramble-core/src/main/java/org/briarproject/bramble/data/MetadataParserImpl.java
View file @
d95a5fd5
...
...
@@ -59,8 +59,8 @@ class MetadataParserImpl implements MetadataParser {
if
(
reader
.
hasBoolean
())
return
reader
.
readBoolean
();
if
(
reader
.
hasLong
())
return
reader
.
readLong
();
if
(
reader
.
hasDouble
())
return
reader
.
readDouble
();
if
(
reader
.
hasString
())
return
reader
.
readString
(
Integer
.
MAX_VALUE
);
if
(
reader
.
hasRaw
())
return
reader
.
readRaw
(
Integer
.
MAX_VALUE
);
if
(
reader
.
hasString
())
return
reader
.
readString
();
if
(
reader
.
hasRaw
())
return
reader
.
readRaw
();
if
(
reader
.
hasList
())
return
reader
.
readList
();
if
(
reader
.
hasDictionary
())
return
reader
.
readDictionary
();
throw
new
FormatException
();
...
...
bramble-core/src/test/java/org/briarproject/bramble/data/BdfReaderImplTest.java
View file @
d95a5fd5
This diff is collapsed.
Click to expand it.
briar-core/src/main/java/org/briarproject/briar/messaging/MessagingModule.java
View file @
d95a5fd5
...
...
@@ -35,8 +35,8 @@ public class MessagingModule {
@Provides
PrivateMessageFactory
providePrivateMessageFactory
(
ClientHelper
clientHelper
)
{
return
new
PrivateMessageFactoryImpl
(
clientHelper
)
;
PrivateMessageFactoryImpl
privateMessageFactory
)
{
return
privateMessageFactory
;
}
@Provides
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment