|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH 07/18] Add size annotations to buffer parameters
Some buffer parameters with a size parameter had no size annotation.
Annotate them with their actual size.
No functional change.
Signed-off-by: Césaire Mounah <cesaire.mounah@xxxxxxxxxx>
---
src/xencrsh/assert.h | 16 ++++++++--------
src/xencrsh/buffer.c | 12 ++++++------
src/xencrsh/buffer.h | 12 ++++++------
src/xencrsh/pdoinquiry.c | 18 +++++++++---------
src/xencrsh/store.c | 2 +-
src/xencrsh/store.h | 8 ++++----
src/xenvbd/base64.c | 6 +++---
src/xenvbd/base64.h | 6 +++---
src/xenvbd/registry.c | 24 ++++++++++++------------
src/xenvbd/registry.h | 16 ++++++++--------
src/xenvbd/target.c | 14 +++++++-------
11 files changed, 67 insertions(+), 67 deletions(-)
diff --git a/src/xencrsh/assert.h b/src/xencrsh/assert.h
index d5b64d6..3692e94 100644
--- a/src/xencrsh/assert.h
+++ b/src/xencrsh/assert.h
@@ -154,10 +154,10 @@ __Bug(
static __inline BOOLEAN
_IsZeroMemory(
- _In_ PCSTR Caller,
- _In_ PCSTR Name,
- _In_ PVOID Buffer,
- _In_ ULONG Length
+ _In_ PCSTR Caller,
+ _In_ PCSTR Name,
+ _In_reads_bytes_(Length) PVOID Buffer,
+ _In_ ULONG Length
)
{
ULONG Offset;
@@ -178,10 +178,10 @@ _IsZeroMemory(
static __inline BOOLEAN
_IsZeroMemory(
- _In_ PCSTR Caller,
- _In_ PCSTR Name,
- _In_ PVOID Buffer,
- _In_ ULONG Length
+ _In_ PCSTR Caller,
+ _In_ PCSTR Name,
+ _In_reads_bytes_(Length) PVOID Buffer,
+ _In_ ULONG Length
)
{
UNREFERENCED_PARAMETER(Caller);
diff --git a/src/xencrsh/buffer.c b/src/xencrsh/buffer.c
index 7d27342..ef897f1 100644
--- a/src/xencrsh/buffer.c
+++ b/src/xencrsh/buffer.c
@@ -150,9 +150,9 @@ BufferPut(
VOID
BufferCopyIn(
- _In_ ULONG BufferId,
- _In_ PVOID Input,
- _In_ ULONG Length
+ _In_ ULONG BufferId,
+ _In_reads_bytes_(Length) PVOID Input,
+ _In_ ULONG Length
)
{
PXENVBD_BUFFER Buf;
@@ -170,9 +170,9 @@ BufferCopyIn(
VOID
BufferCopyOut(
- _In_ ULONG BufferId,
- _Out_ PVOID Output,
- _In_ ULONG Length
+ _In_ ULONG BufferId,
+ _Out_writes_bytes_(Length) PVOID Output,
+ _In_ ULONG Length
)
{
PXENVBD_BUFFER Buf;
diff --git a/src/xencrsh/buffer.h b/src/xencrsh/buffer.h
index 148009f..39df51d 100644
--- a/src/xencrsh/buffer.h
+++ b/src/xencrsh/buffer.h
@@ -58,16 +58,16 @@ BufferPut(
extern VOID
BufferCopyIn(
- _In_ ULONG BufferId,
- _In_ PVOID Input,
- _In_ ULONG Length
+ _In_ ULONG BufferId,
+ _In_reads_bytes_(Length) PVOID Input,
+ _In_ ULONG Length
);
extern VOID
BufferCopyOut(
- _In_ ULONG BufferId,
- _Out_ PVOID Output,
- _In_ ULONG Length
+ _In_ ULONG BufferId,
+ _Out_writes_bytes_(Length) PVOID Output,
+ _In_ ULONG Length
);
#endif // _XENVBD_BUFFER_H
diff --git a/src/xencrsh/pdoinquiry.c b/src/xencrsh/pdoinquiry.c
index 666eb89..9726043 100644
--- a/src/xencrsh/pdoinquiry.c
+++ b/src/xencrsh/pdoinquiry.c
@@ -233,9 +233,9 @@ __DecodeChar(
}
static FORCEINLINE UCHAR
__Decode(
- _Out_ PUCHAR Dest,
- _In_ PSTR Src,
- _In_ ULONG RemainingChars
+ _Out_writes_(3) PUCHAR Dest,
+ _In_reads_(RemainingChars) PSTR Src,
+ _In_ ULONG RemainingChars
)
{
UCHAR Values[4];
@@ -267,10 +267,10 @@ __Decode(
}
static NTSTATUS
__DecodeBase64(
- _In_ PSTR Base64,
- _In_ ULONG Base64Length,
- _Outptr_ PVOID *_Buffer,
- _Out_ PULONG BufferLength
+ _In_ PSTR Base64,
+ _In_ ULONG Base64Length,
+ _Outptr_result_bytebuffer_(*BufferLength) PVOID *_Buffer,
+ _Out_ PULONG BufferLength
)
{
// convert Base64(4chars) into Buffer(3bytes)
@@ -628,8 +628,8 @@ __Min(
}
static FORCEINLINE VOID
__DumpBytes(
- _In_ PUCHAR Bytes,
- _In_ ULONG Length
+ _In_reads_(Length) PUCHAR Bytes,
+ _In_ ULONG Length
)
{
ULONG ThisTime, Index;
diff --git a/src/xencrsh/store.c b/src/xencrsh/store.c
index dbdf818..aa22465 100644
--- a/src/xencrsh/store.c
+++ b/src/xencrsh/store.c
@@ -605,7 +605,7 @@ StoreRead(
_In_opt_ PXENBUS_STORE_TRANSACTION Transaction,
_In_opt_ PSTR Prefix,
_In_ PSTR Node,
- _Outptr_ PCHAR *Value
+ _Outptr_result_z_ PCHAR *Value
)
{
STORE_REQUEST Request;
diff --git a/src/xencrsh/store.h b/src/xencrsh/store.h
index b4a4de4..7adca20 100644
--- a/src/xencrsh/store.h
+++ b/src/xencrsh/store.h
@@ -43,10 +43,10 @@ StoreTerminate();
NTSTATUS
StoreRead(
- _In_opt_ PVOID Transaction,
- _In_opt_ PSTR Prefix,
- _In_ PSTR Node,
- _Outptr_ PCHAR *Value
+ _In_opt_ PVOID Transaction,
+ _In_opt_ PSTR Prefix,
+ _In_ PSTR Node,
+ _Outptr_result_z_ PCHAR *Value
);
NTSTATUS
diff --git a/src/xenvbd/base64.c b/src/xenvbd/base64.c
index c3dbf30..df398aa 100644
--- a/src/xenvbd/base64.c
+++ b/src/xenvbd/base64.c
@@ -113,9 +113,9 @@ __Decode(
NTSTATUS
Base64Decode(
- _In_ PSTR String,
- _Outptr_ PVOID *Binary,
- _Out_ PULONG Length
+ _In_ PSTR String,
+ _Outptr_result_bytebuffer_(*Length) PVOID *Binary,
+ _Out_ PULONG Length
)
{
ULONG StringLength;
diff --git a/src/xenvbd/base64.h b/src/xenvbd/base64.h
index 1806813..b8eab49 100644
--- a/src/xenvbd/base64.h
+++ b/src/xenvbd/base64.h
@@ -42,9 +42,9 @@ Base64Free(
extern NTSTATUS
Base64Decode(
- _In_ PSTR String,
- _Outptr_ PVOID *Binary,
- _Out_ PULONG Length
+ _In_ PSTR String,
+ _Outptr_result_bytebuffer_(*Length) PVOID *Binary,
+ _Out_ PULONG Length
);
#endif // _XENVBD_BASE64_H
diff --git a/src/xenvbd/registry.c b/src/xenvbd/registry.c
index 3efff22..d949460 100644
--- a/src/xenvbd/registry.c
+++ b/src/xenvbd/registry.c
@@ -143,15 +143,15 @@ fail1:
_IRQL_requires_(PASSIVE_LEVEL)
static NTSTATUS
RegistryOpenRoot(
- _In_ PWSTR Path,
- _Out_ PHANDLE Parent,
- _Outptr_ PWCHAR *ChildPath
+ _In_ PWSTR Path,
+ _Out_ PHANDLE Parent,
+ _Outptr_result_z_ PWSTR *ChildPath
)
{
- const WCHAR Prefix[] = L"\\Registry\\Machine\\";
- ULONG Length;
- UNICODE_STRING Unicode;
- NTSTATUS status;
+ const WCHAR Prefix[] = L"\\Registry\\Machine\\";
+ ULONG Length;
+ UNICODE_STRING Unicode;
+ NTSTATUS status;
Length = (ULONG)wcslen(Prefix);
@@ -1117,10 +1117,10 @@ fail1:
_IRQL_requires_(PASSIVE_LEVEL)
NTSTATUS
RegistryQueryBinaryValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _Outptr_ PVOID *Buffer,
- _Out_ PULONG Length
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _Outptr_result_bytebuffer_(*Length) PVOID *Buffer,
+ _Out_ PULONG Length
)
{
ANSI_STRING Ansi;
@@ -1205,7 +1205,7 @@ NTSTATUS
RegistryUpdateBinaryValue(
_In_ HANDLE Key,
_In_ PSTR Name,
- _In_ PVOID Buffer,
+ _In_reads_bytes_(Length) PVOID Buffer,
_In_ ULONG Length
)
{
diff --git a/src/xenvbd/registry.h b/src/xenvbd/registry.h
index b8f80ba..557ab2c 100644
--- a/src/xenvbd/registry.h
+++ b/src/xenvbd/registry.h
@@ -176,19 +176,19 @@ RegistryQuerySzValue(
_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryQueryBinaryValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _Outptr_ PVOID *Buffer,
- _Out_ PULONG Length
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _Outptr_result_bytebuffer_(*Length) PVOID *Buffer,
+ _Out_ PULONG Length
);
_IRQL_requires_(PASSIVE_LEVEL)
extern NTSTATUS
RegistryUpdateBinaryValue(
- _In_ HANDLE Key,
- _In_ PSTR Name,
- _In_ PVOID Buffer,
- _In_ ULONG Length
+ _In_ HANDLE Key,
+ _In_ PSTR Name,
+ _In_reads_bytes_(Length) PVOID Buffer,
+ _In_ ULONG Length
);
_IRQL_requires_(PASSIVE_LEVEL)
diff --git a/src/xenvbd/target.c b/src/xenvbd/target.c
index 0fe3412..cfbcb02 100644
--- a/src/xenvbd/target.c
+++ b/src/xenvbd/target.c
@@ -330,13 +330,13 @@ fail1:
static FORCEINLINE VOID
__TargetModeSense(
- _In_ PXENVBD_TARGET Target,
- _In_ PSCSI_REQUEST_BLOCK Srb,
- _In_ PVOID Data,
- _In_ ULONG Length,
- _Out_ PULONG Size,
- _Out_ PULONG ModeDataLength,
- _Out_ PULONG BlockDescrLength
+ _In_ PXENVBD_TARGET Target,
+ _In_ PSCSI_REQUEST_BLOCK Srb,
+ _Inout_updates_bytes_(Length) PVOID Data,
+ _In_ ULONG Length,
+ _Inout_ PULONG Size,
+ _Inout_ PULONG ModeDataLength,
+ _Inout_ PULONG BlockDescrLength
)
{
const UCHAR PageCode = Cdb_PageCode(Srb);
--
2.55.0.windows.5
--
Césaire Mounah | Vates Windows Guest Tools Engineer
XCP-ng & Xen Orchestra - Vates solutions
web: https://vates.tech
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |