mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
tests: ensure sscan buffer is nul terminated
Avoid reading past the read buffer when sscanf is used.
This commit is contained in:
parent
4ca9d478d4
commit
93c47a2b94
@ -718,6 +718,7 @@ struct KMsg : Source {
|
||||
time_t tt;
|
||||
size_t len;
|
||||
|
||||
buf[ *sz ] = 0;
|
||||
if (sscanf( buf, "%u,%u,%lu,-;%n", &level, &num, &t, &pos ) == 3) {
|
||||
memcpy( newbuf, buf, *sz );
|
||||
tt = time( 0 );
|
||||
@ -735,7 +736,7 @@ struct KMsg : Source {
|
||||
char buf[ buffer_size ];
|
||||
|
||||
if ( dev_kmsg() ) {
|
||||
while ( (sz = ::read( fd, buf, buffer_size ) ) > 0 ) {
|
||||
while ( (sz = ::read( fd, buf, buffer_size - 129 ) ) > 0 ) {
|
||||
transform( buf, &sz );
|
||||
s->push( std::string( buf, sz ) );
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user