File tree Expand file tree Collapse file tree 5 files changed +22
-10
lines changed Expand file tree Collapse file tree 5 files changed +22
-10
lines changed Original file line number Diff line number Diff line change 1
- cmake_minimum_required ( VERSION 3.14 )
1
+ cmake_minimum_required ( VERSION 3.13...99.99 )
2
2
3
- project ( mulle-buffer VERSION 5.0.0 LANGUAGES C)
3
+ project ( mulle-buffer VERSION 5.0.1 LANGUAGES C)
4
4
5
5
6
6
### mulle-sde environment
Original file line number Diff line number Diff line change
1
+ ### 5.0.1
2
+
3
+ * introduced ` MULLE_BUFFER_IS_SPRINTF_INFLEXIBLE ` for that sprintf use special case, to quiet a wrong assert
4
+
1
5
# 5.0.0
2
6
3
7
Original file line number Diff line number Diff line change 59
59
//
60
60
// this is for mulle_sprintf, where we have API that gets storage, where
61
61
// we don't know the size. We can't have buffer->_sentinel wrapping
62
- // around though for our tests
62
+ // around though for our tests. Of course the crazy sentinel value,
63
+ // can't protect us from overwrites (but thats sprintf)
63
64
//
64
65
if ( length == INT_MAX )
65
66
{
68
69
length >>= 1 ;
69
70
buffer -> _sentinel = & buffer -> _storage [ length ];
70
71
}
72
+ buffer -> _type = MULLE_BUFFER_IS_SPRINTF_INFLEXIBLE ;
71
73
}
72
- buffer -> _size = length ;
73
- buffer -> _type = MULLE_BUFFER_IS_INFLEXIBLE ;
74
+ else
75
+ buffer -> _type = MULLE_BUFFER_IS_INFLEXIBLE ;
76
+ buffer -> _size = length ;
74
77
75
78
assert ( buffer -> _sentinel >= buffer -> _storage );
76
79
}
Original file line number Diff line number Diff line change @@ -45,9 +45,10 @@ struct mulle_allocator;
45
45
46
46
enum
47
47
{
48
- MULLE_BUFFER_IS_FLEXIBLE = 0 ,
49
- MULLE_BUFFER_IS_INFLEXIBLE = 1 ,
50
- MULLE_BUFFER_IS_FLUSHABLE = 2
48
+ MULLE_BUFFER_IS_FLEXIBLE = 0 ,
49
+ MULLE_BUFFER_IS_INFLEXIBLE = 1 ,
50
+ MULLE_BUFFER_IS_FLUSHABLE = 2 ,
51
+ MULLE_BUFFER_IS_SPRINTF_INFLEXIBLE = 3 // sentinel is not trustworthy
51
52
};
52
53
53
54
@@ -554,7 +555,11 @@ static inline int _mulle__buffer_intersects_bytes( struct mulle__buffer *buffe
554
555
unsigned char * start ;
555
556
unsigned char * end ;
556
557
557
- if ( ! length )
558
+ // so if the buffer is MULLE_BUFFER_IS_SPRINTF_INFLEXIBLE (which it NEVER
559
+ // should be except when we are doing actually a sprintf implementation)
560
+ // the concept of intersection becomes meaningless, as the sentinel is
561
+ // way off
562
+ if ( ! length || (buffer -> _type & MULLE_BUFFER_IS_SPRINTF_INFLEXIBLE ) == MULLE_BUFFER_IS_SPRINTF_INFLEXIBLE )
558
563
return ( 0 );
559
564
560
565
start = bytes ;
Original file line number Diff line number Diff line change 39
39
#ifndef mulle_buffer_h__
40
40
#define mulle_buffer_h__
41
41
42
- #define MULLE__BUFFER_VERSION ((5UL << 20) | (0 << 8) | 0 )
42
+ #define MULLE__BUFFER_VERSION ((5UL << 20) | (0 << 8) | 1 )
43
43
44
44
#include "include.h"
45
45
#include "mulle--buffer.h"
You can’t perform that action at this time.
0 commit comments