projects
/
tinc
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Convert bitfields to integers in a safe way.
[tinc]
/
lib
/
utils.c
diff --git
a/lib/utils.c
b/lib/utils.c
index
56bcb0b
..
02b7b34
100644
(file)
--- a/
lib/utils.c
+++ b/
lib/utils.c
@@
-100,3
+100,10
@@
const char *winerror(int err) {
}
#endif
}
#endif
+unsigned int bitfield_to_int(void *bitfield, size_t size) {
+ unsigned int value = 0;
+ if(size > sizeof value)
+ size = sizeof value;
+ memcpy(&value, bitfield, size);
+ return value;
+}