Skip to content

Commit de07946

Browse files
committed
project files cleanup
1 parent 15f29c0 commit de07946

File tree

200 files changed

+42
-188981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

200 files changed

+42
-188981
lines changed

Cv1/.gitignore

-14
This file was deleted.

Cv1/read_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Package tcobs_test contains blackbox tests.
1+
// Package tcobsv1_test contains blackbox tests.
22
package tcobsv1_test
33

44
import (
@@ -7,7 +7,7 @@ import (
77
"io"
88
"testing"
99

10-
"github.com/rokath/tcobs/v1"
10+
tcobs "github.com/rokath/tcobs/Cv1"
1111
"github.com/stretchr/testify/assert"
1212
)
1313

Cv1/tcobsDecode.go

+30-9
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func sigilAndOffset(by uint8) (sigil, offset int) {
3939
// For details see TCOBSSpecification.md.
4040
func Decode(d, in []byte) (n int, e error) {
4141
var count int
42+
var b byte
4243
for {
4344
if len(in) == 0 {
4445
return
@@ -84,20 +85,30 @@ func Decode(d, in []byte) (n int, e error) {
8485
goto copyBytes
8586

8687
case R4:
88+
b, e = repeatByte(offset, in)
89+
if e != nil {
90+
return
91+
}
8792
n++
88-
d[len(d)-n] = repeatByte(offset, in)
93+
d[len(d)-n] = b
8994
fallthrough
9095
case R3:
96+
b, e = repeatByte(offset, in)
97+
if e != nil {
98+
return
99+
}
91100
n++
92-
d[len(d)-n] = repeatByte(offset, in)
101+
d[len(d)-n] = b
93102
fallthrough
94103
case R2:
95-
r := repeatByte(offset, in)
104+
b, e = repeatByte(offset, in)
105+
if e != nil {
106+
return
107+
}
96108
n++
97-
d[len(d)-n] = r
109+
d[len(d)-n] = b
98110
n++
99-
d[len(d)-n] = r
100-
111+
d[len(d)-n] = b
101112
goto copyBytes
102113

103114
case Reserved:
@@ -122,10 +133,20 @@ func Decode(d, in []byte) (n int, e error) {
122133
}
123134

124135
// repeatByte returns the value to repeat
125-
func repeatByte(offset int, in []byte) byte {
136+
func repeatByte(offset int, in []byte) (b byte, e error) {
126137
if offset == 0 { // left byte of Ri is a sigil byte (probably N)
127-
return in[len(in)-2] // a buffer cannot start with Ri
138+
if len(in) < 2 {
139+
e = errors.New("inconsistent TCOBS data")
140+
return
141+
}
142+
b = in[len(in)-2] // a buffer cannot start with Ri
143+
return
128144
} else {
129-
return in[len(in)-1]
145+
if len(in) < 1 {
146+
e = errors.New("inconsistent TCOBS data")
147+
return
148+
}
149+
b = in[len(in)-1]
150+
return
130151
}
131152
}

Cv1/test/MDK-ARM_STM32F030R8/Core/Inc/main.h

-109
This file was deleted.

Cv1/test/MDK-ARM_STM32F030R8/Core/Inc/stm32_assert.h

-53
This file was deleted.

Cv1/test/MDK-ARM_STM32F030R8/Core/Inc/stm32f0xx_it.h

-66
This file was deleted.

0 commit comments

Comments
 (0)