projects
/
oweals
/
tinc.git
/ 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.
[oweals/tinc.git]
/
lib
/
utils.c
diff --git
a/lib/utils.c
b/lib/utils.c
index 56bcb0b1b35d8687be63c346ce2690e69063aff4..02b7b3443e626c268bead9bff0bccd03f094b596 100644
(file)
--- a/
lib/utils.c
+++ b/
lib/utils.c
@@
-100,3
+100,10
@@
const char *winerror(int err) {
}
#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;
+}