2
0

700-Add-os_snprintf_error-helper.patch 670 B

1234567891011121314151617181920212223242526272829
  1. Add os_snprintf_error() helper
  2. This can be used to check os_snprintf() return value more consistently.
  3. Signed-off-by: Jouni Malinen <[email protected]>
  4. ---
  5. src/utils/os.h | 6 ++++++
  6. 1 file changed, 6 insertions(+)
  7. diff --git a/src/utils/os.h b/src/utils/os.h
  8. index b9247d8..77250d6 100644
  9. --- a/src/utils/os.h
  10. +++ b/src/utils/os.h
  11. @@ -549,6 +549,12 @@ char * os_strdup(const char *s);
  12. #endif /* OS_NO_C_LIB_DEFINES */
  13. +static inline int os_snprintf_error(size_t size, int res)
  14. +{
  15. + return res < 0 || (unsigned int) res >= size;
  16. +}
  17. +
  18. +
  19. static inline void * os_realloc_array(void *ptr, size_t nmemb, size_t size)
  20. {
  21. if (size && nmemb > (~(size_t) 0) / size)
  22. --
  23. 2.1.3