aboutsummaryrefslogtreecommitdiff
path: root/resource
diff options
context:
space:
mode:
authorXiaoming Ni <nixiaoming@huawei.com>2021-01-04 12:07:38 +0800
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2021-02-10 08:36:17 -0300
commite604a5e4bb61267c58e6b6179209efe74ab5f675 (patch)
tree36f6a102ad8826dd3bc7f2314ab9407f57bfc82f /resource
parent7960c5eea936185dfa9aeaad81b28dbfb53521dd (diff)
downloadglibc-e604a5e4bb61267c58e6b6179209efe74ab5f675.tar
glibc-e604a5e4bb61267c58e6b6179209efe74ab5f675.tar.gz
glibc-e604a5e4bb61267c58e6b6179209efe74ab5f675.tar.bz2
glibc-e604a5e4bb61267c58e6b6179209efe74ab5f675.zip
setrlimit/getrlimit: Use __nonnull to avoid null pointer
Add __nonnull((2)) to the setrlimit()/getrlimit() function declaration to avoid null pointer access. ----- v2 According to the suggestions of the Adhemerval Zanella and Zack Weinberg: use __nonnull() to check null pointers in the compilation phase. do not add pointer check code to setrlimit()/getrlimit(). The validity of the "resource" parameter is checked in the syscall. v1 https://public-inbox.org/libc-alpha/20201230114131.47589-1-nixiaoming@huawei.com/ ----- Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'resource')
-rw-r--r--resource/sys/resource.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/resource/sys/resource.h b/resource/sys/resource.h
index 936a5caf14..d30379d085 100644
--- a/resource/sys/resource.h
+++ b/resource/sys/resource.h
@@ -48,18 +48,19 @@ typedef int __priority_which_t;
Returns 0 if successful, -1 if not (and sets errno). */
#ifndef __USE_FILE_OFFSET64
extern int getrlimit (__rlimit_resource_t __resource,
- struct rlimit *__rlimits) __THROW;
+ struct rlimit *__rlimits) __THROW __nonnull ((2));
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (getrlimit, (__rlimit_resource_t __resource,
- struct rlimit *__rlimits), getrlimit64);
+ struct rlimit *__rlimits), getrlimit64)
+ __nonnull ((2));
# else
# define getrlimit getrlimit64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern int getrlimit64 (__rlimit_resource_t __resource,
- struct rlimit64 *__rlimits) __THROW;
+ struct rlimit64 *__rlimits) __THROW __nonnull ((2));
#endif
/* Set the soft and hard limits for RESOURCE to *RLIMITS.
@@ -67,19 +68,20 @@ extern int getrlimit64 (__rlimit_resource_t __resource,
Return 0 if successful, -1 if not (and sets errno). */
#ifndef __USE_FILE_OFFSET64
extern int setrlimit (__rlimit_resource_t __resource,
- const struct rlimit *__rlimits) __THROW;
+ const struct rlimit *__rlimits) __THROW __nonnull ((2));
#else
# ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (setrlimit, (__rlimit_resource_t __resource,
const struct rlimit *__rlimits),
- setrlimit64);
+ setrlimit64) __nonnull ((2));
# else
# define setrlimit setrlimit64
# endif
#endif
#ifdef __USE_LARGEFILE64
extern int setrlimit64 (__rlimit_resource_t __resource,
- const struct rlimit64 *__rlimits) __THROW;
+ const struct rlimit64 *__rlimits) __THROW
+ __nonnull ((2));
#endif
/* Return resource usage information on process indicated by WHO