Code Review
/
apps
/
agl-service-can-low-level.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
review
|
tree
raw
|
patch
| inline |
side by side
(parent:
b214de4
)
Add buffer size check in test_decode1.c example.
author
Petteri Aimonen
<jpa@git.mail.kapsi.fi>
Tue, 18 Sep 2012 13:48:43 +0000
(16:48 +0300)
committer
Petteri Aimonen
<jpa@git.mail.kapsi.fi>
Tue, 18 Sep 2012 13:51:22 +0000
(16:51 +0300)
This check gives a better error message in case you test stuff
and have a message longer than 512 bytes.
Update issue 34
Status: FixedInGit
tests/test_decode1.c
patch
|
blob
|
history
diff --git
a/tests/test_decode1.c
b/tests/test_decode1.c
index
64eb468
..
56bbd8f
100644
(file)
--- a/
tests/test_decode1.c
+++ b/
tests/test_decode1.c
@@
-63,6
+63,12
@@
int main()
uint8_t buffer[512];
size_t count = fread(buffer, 1, sizeof(buffer), stdin);
+ if (!feof(stdin))
+ {
+ printf("Message does not fit in buffer\n");
+ return 1;
+ }
+
/* Construct a pb_istream_t for reading from the buffer */
pb_istream_t stream = pb_istream_from_buffer(buffer, count);