Skip to content

Commit a6aa289

Browse files
committed
zend: introducing ZEND_ELEMENT_COUNT for struct's dynamic arrays.
It is mostly for ubsan and helping array bound checking.
1 parent 9bb341d commit a6aa289

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

Zend/zend_portability.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -327,6 +327,14 @@ char *alloca();
327327
# define HAVE_BUILTIN_CONSTANT_P
328328
#endif
329329

330+
#if __has_attribute(element_count)
331+
#define ZEND_ELEMENT_COUNT(m) __attribute__((element_count(m)))
332+
#elif __has_attribute(counted_by)
333+
#define ZEND_ELEMENT_COUNT(m) __attribute__((counted_by(m)))
334+
#else
335+
#define ZEND_ELEMENT_COUNT(m)
336+
#endif
337+
330338
#ifdef HAVE_BUILTIN_CONSTANT_P
331339
# define ZEND_CONST_COND(_condition, _default) \
332340
(__builtin_constant_p(_condition) ? (_condition) : (_default))

sapi/fpm/fpm/fpm_scoreboard.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ struct fpm_scoreboard_s {
6767
int free_proc;
6868
unsigned long int slow_rq;
6969
struct fpm_scoreboard_s *shared;
70-
struct fpm_scoreboard_proc_s procs[];
70+
struct fpm_scoreboard_proc_s procs[] ZEND_ELEMENT_COUNT(nprocs);
7171
};
7272

7373
int fpm_scoreboard_init_main(void);

0 commit comments

Comments
 (0)