diff options
| author | Tomasz Kramkowski <tk@the-tk.com> | 2021-11-07 22:18:21 +0000 |
|---|---|---|
| committer | Tomasz Kramkowski <tk@the-tk.com> | 2021-11-07 22:18:21 +0000 |
| commit | 383c232bc2f1661923177437e48ea4cf6bd4e304 (patch) | |
| tree | 6163457d1c53cad97aa36bbf9619e6bf0713107f /common.h | |
| parent | 4251c280acbddda225bea6be79c4b3dbe36c2193 (diff) | |
| download | pack-383c232bc2f1661923177437e48ea4cf6bd4e304.tar.gz pack-383c232bc2f1661923177437e48ea4cf6bd4e304.tar.xz pack-383c232bc2f1661923177437e48ea4cf6bd4e304.zip | |
use safe_islower to avoid UB
Diffstat (limited to 'common.h')
| -rw-r--r-- | common.h | 8 |
1 files changed, 8 insertions, 0 deletions
@@ -7,6 +7,7 @@ #include <limits.h> #include <stddef.h> +#include <ctype.h> #include "pack.h" @@ -39,6 +40,13 @@ T(LLONG, signed, long long, long long) \ T(ULLONG, unsigned, long long, long long) +// safe_islower: islower but no domain errors +static inline int safe_islower(int c) +{ + if (c < 0 || c > UCHAR_MAX) return 0; + return islower(c); +} + size_t getsize(enum pack_type t); #endif // !PACK_COMMON_H |
