projects
/
visomat-utils.git
/ commitdiff
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
0daf840
)
visomat-data-downloader: more precise data validation in decode_eeprom()
author
Antonio Ospite <ao2@ao2.it>
Sat, 9 Jan 2016 18:12:38 +0000
(19:12 +0100)
committer
Antonio Ospite <ao2@ao2.it>
Sat, 9 Jan 2016 18:12:38 +0000
(19:12 +0100)
src/visomat-data-downloader.c
patch
|
blob
|
history
diff --git
a/src/visomat-data-downloader.c
b/src/visomat-data-downloader.c
index
1b4cde9
..
a53f72c
100644
(file)
--- a/
src/visomat-data-downloader.c
+++ b/
src/visomat-data-downloader.c
@@
-133,8
+133,15
@@
static int decode_eeprom(uint8_t *buffer,
struct datetime d;
struct pressure p;
struct datetime d;
struct pressure p;
- if (buffer[0] != STX || buffer[1] != 'M' || buffer[len - 1] != ETX)
+ if (buffer[0] != STX || buffer[1] != 'M') {
+ fprintf(stderr, "Usupported data.\n");
return -EINVAL;
return -EINVAL;
+ }
+
+ if (buffer[len - 1] != ETX) {
+ fprintf(stderr, "Bad terminator in data. Buffer too small?\n");
+ return -EINVAL;
+ }
/* skip the initial STX */
i = 1;
/* skip the initial STX */
i = 1;