Skip to content

Commit

Permalink
Fix buffer overflow in compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielSchiavini committed Jul 1, 2024
1 parent a3f6c72 commit df11df1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
18 changes: 7 additions & 11 deletions src/main/kotlin/org/vyperlang/plugin/docker/VyperCompilerDocker.kt
Original file line number Diff line number Diff line change
Expand Up @@ -139,18 +139,14 @@ class VyperCompilerDocker(
}

private class VyperFramesAdapter : ResultCallback.Adapter<Frame>() {
private val items = mutableListOf<Frame>()

val errors: List<String> get() = items
.filter { it.streamType == StreamType.STDERR }
.map { String(it.payload).replace("\n", "").trim() }

val logs: List<String> get() = items
.filter { it.streamType == StreamType.STDOUT }
.map { String(it.payload).replace("\n", "").trim() }

val errors = mutableListOf<String>()
val logs = mutableListOf<String>()
override fun onNext(item: Frame) {
items.add(item)
when (item.streamType) {
StreamType.STDERR -> errors
StreamType.STDOUT -> logs
else -> throw IllegalStateException("Unknown stream type " + item.streamType)
}.add(String(item.payload).trim())
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<id>org.vyperlang.plugin.vyper-plugin</id>
<name>Vyper</name>
<version>0.0.0<!-- updated by changelog plugin --></version>
<vendor email="https://github.com/NikitaMishin/vyper-plugin" url="https://github.com/NikitaMishin/vyper-plugin">
<vendor url="https://github.com/NikitaMishin/vyper-plugin">
VyperPluginSupport
</vendor>
<idea-version since-build="223.7571.182"/>
Expand Down
2 changes: 1 addition & 1 deletion src/test/kotlin/org/vyperlang/plugin/parser/TestCompile.kt
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class TestCompile : BasePlatformTestCase() {
fun testCompile() {
val result = compile("example.vy")
assertEmpty(result.stderr)
assertMatches(result.stdout.joinToString(""), "^([0-9a-f]{2})+$".toRegex())
assertMatches(result.stdout.joinToString(""), "^0x([0-9a-f]{2})+$".toRegex())
assertEquals(result.statusDocker, StatusDocker.SUCCESS)
}

Expand Down

0 comments on commit df11df1

Please sign in to comment.