Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
briar
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Julian Dehm
briar
Commits
9ad41ea2
Unverified
Commit
9ad41ea2
authored
9 years ago
by
akwizgran
Browse files
Options
Downloads
Patches
Plain Diff
Check UTF-8 length of transport ID.
parent
5a6ab9bb
Loading
Loading
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
briar-api/src/org/briarproject/api/TransportId.java
+7
-2
7 additions, 2 deletions
briar-api/src/org/briarproject/api/TransportId.java
with
7 additions
and
2 deletions
briar-api/src/org/briarproject/api/TransportId.java
+
7
−
2
View file @
9ad41ea2
package
org.briarproject.api
;
import
java.nio.charset.Charset
;
/**
* Type-safe wrapper for a string that uniquely identifies a transport plugin.
*/
public
class
TransportId
{
/** The maximum length of transport identifier in UTF-8 bytes. */
/**
* The maximum length of transport identifier in UTF-8 bytes.
*/
public
static
int
MAX_TRANSPORT_ID_LENGTH
=
10
;
private
final
String
id
;
public
TransportId
(
String
id
)
{
if
(
id
.
length
()
==
0
||
id
.
length
()
>
MAX_TRANSPORT_ID_LENGTH
)
byte
[]
b
=
id
.
getBytes
(
Charset
.
forName
(
"UTF-8"
));
if
(
b
.
length
==
0
||
b
.
length
>
MAX_TRANSPORT_ID_LENGTH
)
throw
new
IllegalArgumentException
();
this
.
id
=
id
;
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment