diff options
author | Seyediman Seyedarab <ImanDevel@gmail.com> | 2025-09-18 13:01:58 +0800 |
---|---|---|
committer | Joerg Roedel <joerg.roedel@amd.com> | 2025-09-19 09:43:19 +0200 |
commit | 75c02a037609f34db17e91be195cedb33b61bae0 (patch) | |
tree | d75e5581fa83275576f4bbabc24f8e024a00f9fd /rust/helpers/bitops.c | |
parent | 1b237f190eb3d36f52dffe07a40b5eb210280e00 (diff) |
iommu/vt-d: Replace snprintf with scnprintf in dmar_latency_snapshot()
snprintf() returns the number of bytes that would have been written, not
the number actually written. Using this for offset tracking can cause
buffer overruns if truncation occurs.
Replace snprintf() with scnprintf() to ensure the offset stays within
bounds.
Since scnprintf() never returns a negative value, and zero is not possible
in this context because 'bytes' starts at 0 and 'size - bytes' is
DEBUG_BUFFER_SIZE in the first call, which is large enough to hold the
string literals used, the return value is always positive. An integer
overflow is also completely out of reach here due to the small and fixed
buffer size. The error check in latency_show_one() is therefore
unnecessary. Remove it and make dmar_latency_snapshot() return void.
Signed-off-by: Seyediman Seyedarab <ImanDevel@gmail.com>
Link: https://lore.kernel.org/r/20250731225048.131364-1-ImanDevel@gmail.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
Diffstat (limited to 'rust/helpers/bitops.c')
0 files changed, 0 insertions, 0 deletions