Kernel: Reading from negative offset in fb dev gives out info
This commit is contained in:
parent
09b7cb2f33
commit
d86ecf4f61
|
@ -82,8 +82,20 @@ namespace Kernel
|
||||||
|
|
||||||
BAN::ErrorOr<size_t> FramebufferDevice::read_impl(off_t offset, BAN::ByteSpan buffer)
|
BAN::ErrorOr<size_t> FramebufferDevice::read_impl(off_t offset, BAN::ByteSpan buffer)
|
||||||
{
|
{
|
||||||
|
// Reading from negative offset will fill buffer with framebuffer info
|
||||||
if (offset < 0)
|
if (offset < 0)
|
||||||
return BAN::Error::from_errno(EINVAL);
|
{
|
||||||
|
if (buffer.size() < sizeof(framebuffer_info_t))
|
||||||
|
return BAN::Error::from_errno(ENOBUFS);
|
||||||
|
|
||||||
|
auto& fb_info = buffer.as<framebuffer_info_t>();
|
||||||
|
fb_info.width = m_width;
|
||||||
|
fb_info.height = m_height;
|
||||||
|
fb_info.bpp = m_bpp;
|
||||||
|
|
||||||
|
return sizeof(framebuffer_info_t);
|
||||||
|
}
|
||||||
|
|
||||||
if ((size_t)offset >= m_width * m_height * bytes_per_pixel_internal)
|
if ((size_t)offset >= m_width * m_height * bytes_per_pixel_internal)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
#ifndef _FRAMEBUFFER_H
|
||||||
|
#define _FRAMEBUFFER_H 1
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
|
|
||||||
|
__BEGIN_DECLS
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
|
struct framebuffer_info_t
|
||||||
|
{
|
||||||
|
uint32_t width;
|
||||||
|
uint32_t height;
|
||||||
|
uint8_t bpp;
|
||||||
|
};
|
||||||
|
|
||||||
|
__END_DECLS
|
||||||
|
|
||||||
|
#endif
|
Loading…
Reference in New Issue