Coverage Report

Created: 2022-10-14 11:19

/src/php-src/Zend/zend_ini.c
Line
Count
Source (jump to first uncovered line)
1
/*
2
   +----------------------------------------------------------------------+
3
   | Zend Engine                                                          |
4
   +----------------------------------------------------------------------+
5
   | Copyright (c) Zend Technologies Ltd. (http://www.zend.com)           |
6
   +----------------------------------------------------------------------+
7
   | This source file is subject to version 2.00 of the Zend license,     |
8
   | that is bundled with this package in the file LICENSE, and is        |
9
   | available through the world-wide-web at the following url:           |
10
   | http://www.zend.com/license/2_00.txt.                                |
11
   | If you did not receive a copy of the Zend license and are unable to  |
12
   | obtain it through the world-wide-web, please send a note to          |
13
   | license@zend.com so we can mail you a copy immediately.              |
14
   +----------------------------------------------------------------------+
15
   | Author: Zeev Suraski <zeev@php.net>                                  |
16
   +----------------------------------------------------------------------+
17
*/
18
19
#include "zend.h"
20
#include "zend_sort.h"
21
#include "zend_API.h"
22
#include "zend_ini.h"
23
#include "zend_alloc.h"
24
#include "zend_operators.h"
25
#include "zend_strtod.h"
26
27
static HashTable *registered_zend_ini_directives;
28
29
#define NO_VALUE_PLAINTEXT    "no value"
30
#define NO_VALUE_HTML     "<i>no value</i>"
31
32
/*
33
 * hash_apply functions
34
 */
35
static int zend_remove_ini_entries(zval *el, void *arg) /* {{{ */
36
0
{
37
0
  zend_ini_entry *ini_entry = (zend_ini_entry *)Z_PTR_P(el);
38
0
  int module_number = *(int *)arg;
39
40
0
  return ini_entry->module_number == module_number;
41
0
}
42
/* }}} */
43
44
static int zend_restore_ini_entry_cb(zend_ini_entry *ini_entry, int stage) /* {{{ */
45
0
{
46
0
  int result = FAILURE;
47
48
0
  if (ini_entry->modified) {
49
0
    if (ini_entry->on_modify) {
50
0
      zend_try {
51
      /* even if on_modify bails out, we have to continue on with restoring,
52
        since there can be allocated variables that would be freed on MM shutdown
53
        and would lead to memory corruption later ini entry is modified again */
54
0
        result = ini_entry->on_modify(ini_entry, ini_entry->orig_value, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage);
55
0
      } zend_end_try();
56
0
    }
57
0
    if (stage == ZEND_INI_STAGE_RUNTIME && result == FAILURE) {
58
      /* runtime failure is OK */
59
0
      return 1;
60
0
    }
61
0
    if (ini_entry->value != ini_entry->orig_value) {
62
0
      zend_string_release(ini_entry->value);
63
0
    }
64
0
    ini_entry->value = ini_entry->orig_value;
65
0
    ini_entry->modifiable = ini_entry->orig_modifiable;
66
0
    ini_entry->modified = 0;
67
0
    ini_entry->orig_value = NULL;
68
0
    ini_entry->orig_modifiable = 0;
69
0
  }
70
0
  return 0;
71
0
}
72
/* }}} */
73
74
static void free_ini_entry(zval *zv) /* {{{ */
75
0
{
76
0
  zend_ini_entry *entry = (zend_ini_entry*)Z_PTR_P(zv);
77
78
0
  zend_string_release_ex(entry->name, 1);
79
0
  if (entry->value) {
80
0
    zend_string_release(entry->value);
81
0
  }
82
0
  if (entry->orig_value) {
83
0
    zend_string_release_ex(entry->orig_value, 1);
84
0
  }
85
0
  free(entry);
86
0
}
87
/* }}} */
88
89
/*
90
 * Startup / shutdown
91
 */
92
ZEND_API int zend_ini_startup(void) /* {{{ */
93
3.64k
{
94
3.64k
  registered_zend_ini_directives = (HashTable *) malloc(sizeof(HashTable));
95
96
3.64k
  EG(ini_directives) = registered_zend_ini_directives;
97
3.64k
  EG(modified_ini_directives) = NULL;
98
3.64k
  EG(error_reporting_ini_entry) = NULL;
99
3.64k
  zend_hash_init_ex(registered_zend_ini_directives, 128, NULL, free_ini_entry, 1, 0);
100
3.64k
  return SUCCESS;
101
3.64k
}
102
/* }}} */
103
104
ZEND_API int zend_ini_shutdown(void) /* {{{ */
105
0
{
106
0
  zend_ini_dtor(EG(ini_directives));
107
0
  return SUCCESS;
108
0
}
109
/* }}} */
110
111
ZEND_API void zend_ini_dtor(HashTable *ini_directives) /* {{{ */
112
0
{
113
0
  zend_hash_destroy(ini_directives);
114
0
  free(ini_directives);
115
0
}
116
/* }}} */
117
118
ZEND_API int zend_ini_global_shutdown(void) /* {{{ */
119
0
{
120
0
  zend_hash_destroy(registered_zend_ini_directives);
121
0
  free(registered_zend_ini_directives);
122
0
  return SUCCESS;
123
0
}
124
/* }}} */
125
126
ZEND_API int zend_ini_deactivate(void) /* {{{ */
127
395k
{
128
395k
  if (EG(modified_ini_directives)) {
129
0
    zend_ini_entry *ini_entry;
130
131
0
    ZEND_HASH_FOREACH_PTR(EG(modified_ini_directives), ini_entry) {
132
0
      zend_restore_ini_entry_cb(ini_entry, ZEND_INI_STAGE_DEACTIVATE);
133
0
    } ZEND_HASH_FOREACH_END();
134
0
    zend_hash_destroy(EG(modified_ini_directives));
135
0
    FREE_HASHTABLE(EG(modified_ini_directives));
136
0
    EG(modified_ini_directives) = NULL;
137
0
  }
138
395k
  return SUCCESS;
139
395k
}
140
/* }}} */
141
142
#ifdef ZTS
143
static void copy_ini_entry(zval *zv) /* {{{ */
144
{
145
  zend_ini_entry *old_entry = (zend_ini_entry*)Z_PTR_P(zv);
146
  zend_ini_entry *new_entry = pemalloc(sizeof(zend_ini_entry), 1);
147
148
  Z_PTR_P(zv) = new_entry;
149
  memcpy(new_entry, old_entry, sizeof(zend_ini_entry));
150
  if (old_entry->name) {
151
    new_entry->name = zend_string_dup(old_entry->name, 1);
152
  }
153
  if (old_entry->value) {
154
    new_entry->value = zend_string_dup(old_entry->value, 1);
155
  }
156
  if (old_entry->orig_value) {
157
    new_entry->orig_value = zend_string_dup(old_entry->orig_value, 1);
158
  }
159
}
160
/* }}} */
161
162
ZEND_API int zend_copy_ini_directives(void) /* {{{ */
163
{
164
  EG(modified_ini_directives) = NULL;
165
  EG(error_reporting_ini_entry) = NULL;
166
  EG(ini_directives) = (HashTable *) malloc(sizeof(HashTable));
167
  zend_hash_init_ex(EG(ini_directives), registered_zend_ini_directives->nNumOfElements, NULL, free_ini_entry, 1, 0);
168
  zend_hash_copy(EG(ini_directives), registered_zend_ini_directives, copy_ini_entry);
169
  return SUCCESS;
170
}
171
/* }}} */
172
#endif
173
174
static int ini_key_compare(Bucket *f, Bucket *s) /* {{{ */
175
0
{
176
0
  if (!f->key && !s->key) { /* both numeric */
177
0
    if (f->h > s->h) {
178
0
      return -1;
179
0
    } else if (f->h < s->h) {
180
0
      return 1;
181
0
    }
182
0
    return 0;
183
0
  } else if (!f->key) { /* f is numeric, s is not */
184
0
    return -1;
185
0
  } else if (!s->key) { /* s is numeric, f is not */
186
0
    return 1;
187
0
  } else { /* both strings */
188
0
    return zend_binary_strcasecmp(ZSTR_VAL(f->key), ZSTR_LEN(f->key), ZSTR_VAL(s->key), ZSTR_LEN(s->key));
189
0
  }
190
0
}
191
/* }}} */
192
193
ZEND_API void zend_ini_sort_entries(void) /* {{{ */
194
0
{
195
0
  zend_hash_sort(EG(ini_directives), ini_key_compare, 0);
196
0
}
197
/* }}} */
198
199
/*
200
 * Registration / unregistration
201
 */
202
ZEND_API int zend_register_ini_entries(const zend_ini_entry_def *ini_entry, int module_number) /* {{{ */
203
36.4k
{
204
36.4k
  zend_ini_entry *p;
205
36.4k
  zval *default_value;
206
36.4k
  HashTable *directives = registered_zend_ini_directives;
207
208
#ifdef ZTS
209
  /* if we are called during the request, eg: from dl(),
210
   * then we should not touch the global directives table,
211
   * and should update the per-(request|thread) version instead.
212
   * This solves two problems: one is that ini entries for dl()'d
213
   * extensions will now work, and the second is that updating the
214
   * global hash here from dl() is not mutex protected and can
215
   * lead to death.
216
   */
217
  if (directives != EG(ini_directives)) {
218
    directives = EG(ini_directives);
219
  }
220
#endif
221
222
499k
  while (ini_entry->name) {
223
463k
    p = pemalloc(sizeof(zend_ini_entry), 1);
224
463k
    p->name = zend_string_init_interned(ini_entry->name, ini_entry->name_length, 1);
225
463k
    p->on_modify = ini_entry->on_modify;
226
463k
    p->mh_arg1 = ini_entry->mh_arg1;
227
463k
    p->mh_arg2 = ini_entry->mh_arg2;
228
463k
    p->mh_arg3 = ini_entry->mh_arg3;
229
463k
    p->value = NULL;
230
463k
    p->orig_value = NULL;
231
463k
    p->displayer = ini_entry->displayer;
232
463k
    p->modifiable = ini_entry->modifiable;
233
234
463k
    p->orig_modifiable = 0;
235
463k
    p->modified = 0;
236
463k
    p->module_number = module_number;
237
238
463k
    if (zend_hash_add_ptr(directives, p->name, (void*)p) == NULL) {
239
0
      if (p->name) {
240
0
        zend_string_release_ex(p->name, 1);
241
0
      }
242
0
      zend_unregister_ini_entries(module_number);
243
0
      return FAILURE;
244
0
    }
245
463k
    if (((default_value = zend_get_configuration_directive(p->name)) != NULL) &&
246
21.8k
            (!p->on_modify || p->on_modify(p, Z_STR_P(default_value), p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP) == SUCCESS)) {
247
248
21.8k
      p->value = zend_new_interned_string(zend_string_copy(Z_STR_P(default_value)));
249
441k
    } else {
250
441k
      p->value = ini_entry->value ?
251
335k
        zend_string_init_interned(ini_entry->value, ini_entry->value_length, 1) : NULL;
252
253
441k
      if (p->on_modify) {
254
382k
        p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, ZEND_INI_STAGE_STARTUP);
255
382k
      }
256
441k
    }
257
463k
    ini_entry++;
258
463k
  }
259
36.4k
  return SUCCESS;
260
36.4k
}
261
/* }}} */
262
263
ZEND_API void zend_unregister_ini_entries(int module_number) /* {{{ */
264
0
{
265
0
  zend_hash_apply_with_argument(registered_zend_ini_directives, zend_remove_ini_entries, (void *) &module_number);
266
0
}
267
/* }}} */
268
269
#ifdef ZTS
270
ZEND_API void zend_ini_refresh_caches(int stage) /* {{{ */
271
{
272
  zend_ini_entry *p;
273
274
  ZEND_HASH_FOREACH_PTR(EG(ini_directives), p) {
275
    if (p->on_modify) {
276
      p->on_modify(p, p->value, p->mh_arg1, p->mh_arg2, p->mh_arg3, stage);
277
    }
278
  } ZEND_HASH_FOREACH_END();
279
}
280
/* }}} */
281
#endif
282
283
ZEND_API int zend_alter_ini_entry(zend_string *name, zend_string *new_value, int modify_type, int stage) /* {{{ */
284
0
{
285
286
0
  return zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
287
0
}
288
/* }}} */
289
290
ZEND_API int zend_alter_ini_entry_chars(zend_string *name, const char *value, size_t value_length, int modify_type, int stage) /* {{{ */
291
0
{
292
0
    int ret;
293
0
    zend_string *new_value;
294
295
0
  new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST));
296
0
  ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, 0);
297
0
  zend_string_release(new_value);
298
0
  return ret;
299
0
}
300
/* }}} */
301
302
ZEND_API int zend_alter_ini_entry_chars_ex(zend_string *name, const char *value, size_t value_length, int modify_type, int stage, int force_change) /* {{{ */
303
0
{
304
0
    int ret;
305
0
    zend_string *new_value;
306
307
0
  new_value = zend_string_init(value, value_length, !(stage & ZEND_INI_STAGE_IN_REQUEST));
308
0
  ret = zend_alter_ini_entry_ex(name, new_value, modify_type, stage, force_change);
309
0
  zend_string_release(new_value);
310
0
  return ret;
311
0
}
312
/* }}} */
313
314
ZEND_API int zend_alter_ini_entry_ex(zend_string *name, zend_string *new_value, int modify_type, int stage, int force_change) /* {{{ */
315
0
{
316
0
  zend_ini_entry *ini_entry;
317
0
  zend_string *duplicate;
318
0
  zend_bool modifiable;
319
0
  zend_bool modified;
320
321
0
  if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL) {
322
0
    return FAILURE;
323
0
  }
324
325
0
  modifiable = ini_entry->modifiable;
326
0
  modified = ini_entry->modified;
327
328
0
  if (stage == ZEND_INI_STAGE_ACTIVATE && modify_type == ZEND_INI_SYSTEM) {
329
0
    ini_entry->modifiable = ZEND_INI_SYSTEM;
330
0
  }
331
332
0
  if (!force_change) {
333
0
    if (!(ini_entry->modifiable & modify_type)) {
334
0
      return FAILURE;
335
0
    }
336
0
  }
337
338
0
  if (ini_entry->modifiable != ZEND_INI_SYSTEM) {
339
0
    if (!EG(modified_ini_directives)) {
340
0
      ALLOC_HASHTABLE(EG(modified_ini_directives));
341
0
      zend_hash_init(EG(modified_ini_directives), 8, NULL, NULL, 0);
342
0
    }
343
0
    if (!modified) {
344
0
      ini_entry->orig_value = ini_entry->value;
345
0
      ini_entry->orig_modifiable = modifiable;
346
0
      ini_entry->modified = 1;
347
0
      zend_hash_add_ptr(EG(modified_ini_directives), ini_entry->name, ini_entry);
348
0
    }
349
0
  }
350
351
0
  duplicate = zend_string_copy(new_value);
352
353
0
  if (!ini_entry->on_modify
354
0
    || ini_entry->on_modify(ini_entry, duplicate, ini_entry->mh_arg1, ini_entry->mh_arg2, ini_entry->mh_arg3, stage) == SUCCESS) {
355
0
    if (modified && ini_entry->orig_value != ini_entry->value) { /* we already changed the value, free the changed value */
356
0
      zend_string_release(ini_entry->value);
357
0
    }
358
0
    ini_entry->value = duplicate;
359
0
  } else {
360
0
    zend_string_release(duplicate);
361
0
    return FAILURE;
362
0
  }
363
364
0
  return SUCCESS;
365
0
}
366
/* }}} */
367
368
ZEND_API int zend_restore_ini_entry(zend_string *name, int stage) /* {{{ */
369
0
{
370
0
  zend_ini_entry *ini_entry;
371
372
0
  if ((ini_entry = zend_hash_find_ptr(EG(ini_directives), name)) == NULL ||
373
0
    (stage == ZEND_INI_STAGE_RUNTIME && (ini_entry->modifiable & ZEND_INI_USER) == 0)) {
374
0
    return FAILURE;
375
0
  }
376
377
0
  if (EG(modified_ini_directives)) {
378
0
    if (zend_restore_ini_entry_cb(ini_entry, stage) == 0) {
379
0
      zend_hash_del(EG(modified_ini_directives), name);
380
0
    } else {
381
0
      return FAILURE;
382
0
    }
383
0
  }
384
385
0
  return SUCCESS;
386
0
}
387
/* }}} */
388
389
ZEND_API int zend_ini_register_displayer(const char *name, uint32_t name_length, void (*displayer)(zend_ini_entry *ini_entry, int type)) /* {{{ */
390
0
{
391
0
  zend_ini_entry *ini_entry;
392
393
0
  ini_entry = zend_hash_str_find_ptr(registered_zend_ini_directives, name, name_length);
394
0
  if (ini_entry == NULL) {
395
0
    return FAILURE;
396
0
  }
397
398
0
  ini_entry->displayer = displayer;
399
0
  return SUCCESS;
400
0
}
401
/* }}} */
402
403
/*
404
 * Data retrieval
405
 */
406
407
ZEND_API zend_long zend_ini_long(const char *name, size_t name_length, int orig) /* {{{ */
408
0
{
409
0
  zend_ini_entry *ini_entry;
410
411
0
  ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
412
0
  if (ini_entry) {
413
0
    if (orig && ini_entry->modified) {
414
0
      return (ini_entry->orig_value ? ZEND_STRTOL(ZSTR_VAL(ini_entry->orig_value), NULL, 0) : 0);
415
0
    } else {
416
0
      return (ini_entry->value      ? ZEND_STRTOL(ZSTR_VAL(ini_entry->value), NULL, 0)      : 0);
417
0
    }
418
0
  }
419
420
0
  return 0;
421
0
}
422
/* }}} */
423
424
ZEND_API double zend_ini_double(const char *name, size_t name_length, int orig) /* {{{ */
425
0
{
426
0
  zend_ini_entry *ini_entry;
427
428
0
  ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
429
0
  if (ini_entry) {
430
0
    if (orig && ini_entry->modified) {
431
0
      return (double) (ini_entry->orig_value ? zend_strtod(ZSTR_VAL(ini_entry->orig_value), NULL) : 0.0);
432
0
    } else {
433
0
      return (double) (ini_entry->value      ? zend_strtod(ZSTR_VAL(ini_entry->value), NULL)      : 0.0);
434
0
    }
435
0
  }
436
437
0
  return 0.0;
438
0
}
439
/* }}} */
440
441
ZEND_API char *zend_ini_string_ex(const char *name, size_t name_length, int orig, zend_bool *exists) /* {{{ */
442
14.5k
{
443
14.5k
  zend_ini_entry *ini_entry;
444
445
14.5k
  ini_entry = zend_hash_str_find_ptr(EG(ini_directives), name, name_length);
446
14.5k
  if (ini_entry) {
447
14.5k
    if (exists) {
448
3.64k
      *exists = 1;
449
3.64k
    }
450
451
14.5k
    if (orig && ini_entry->modified) {
452
0
      return ini_entry->orig_value ? ZSTR_VAL(ini_entry->orig_value) : NULL;
453
14.5k
    } else {
454
7.29k
      return ini_entry->value ? ZSTR_VAL(ini_entry->value) : NULL;
455
14.5k
    }
456
0
  } else {
457
0
    if (exists) {
458
0
      *exists = 0;
459
0
    }
460
0
    return NULL;
461
0
  }
462
14.5k
}
463
/* }}} */
464
465
ZEND_API char *zend_ini_string(const char *name, size_t name_length, int orig) /* {{{ */
466
3.64k
{
467
3.64k
  zend_bool exists = 1;
468
3.64k
  char *return_value;
469
470
3.64k
  return_value = zend_ini_string_ex(name, name_length, orig, &exists);
471
3.64k
  if (!exists) {
472
0
    return NULL;
473
3.64k
  } else if (!return_value) {
474
3.64k
    return_value = "";
475
3.64k
  }
476
3.64k
  return return_value;
477
3.64k
}
478
/* }}} */
479
480
ZEND_API zend_string *zend_ini_get_value(zend_string *name) /* {{{ */
481
0
{
482
0
  zend_ini_entry *ini_entry;
483
484
0
  ini_entry = zend_hash_find_ptr(EG(ini_directives), name);
485
0
  if (ini_entry) {
486
0
    return ini_entry->value ? ini_entry->value : ZSTR_EMPTY_ALLOC();
487
0
  } else {
488
0
    return NULL;
489
0
  }
490
0
}
491
/* }}} */
492
493
ZEND_API zend_bool zend_ini_parse_bool(zend_string *str)
494
116k
{
495
116k
  if ((ZSTR_LEN(str) == 4 && strcasecmp(ZSTR_VAL(str), "true") == 0)
496
116k
    || (ZSTR_LEN(str) == 3 && strcasecmp(ZSTR_VAL(str), "yes") == 0)
497
116k
    || (ZSTR_LEN(str) == 2 && strcasecmp(ZSTR_VAL(str), "on") == 0)) {
498
0
    return 1;
499
116k
  } else {
500
116k
    return atoi(ZSTR_VAL(str)) != 0;
501
116k
  }
502
116k
}
503
504
ZEND_INI_DISP(zend_ini_boolean_displayer_cb) /* {{{ */
505
0
{
506
0
  int value;
507
0
  zend_string *tmp_value;
508
509
0
  if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
510
0
    tmp_value = (ini_entry->orig_value ? ini_entry->orig_value : NULL );
511
0
  } else if (ini_entry->value) {
512
0
    tmp_value = ini_entry->value;
513
0
  } else {
514
0
    tmp_value = NULL;
515
0
  }
516
517
0
  if (tmp_value) {
518
0
    value = zend_ini_parse_bool(tmp_value);
519
0
  } else {
520
0
    value = 0;
521
0
  }
522
523
0
  if (value) {
524
0
    ZEND_PUTS("On");
525
0
  } else {
526
0
    ZEND_PUTS("Off");
527
0
  }
528
0
}
529
/* }}} */
530
531
ZEND_INI_DISP(zend_ini_color_displayer_cb) /* {{{ */
532
0
{
533
0
  char *value;
534
535
0
  if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
536
0
    value = ZSTR_VAL(ini_entry->orig_value);
537
0
  } else if (ini_entry->value) {
538
0
    value = ZSTR_VAL(ini_entry->value);
539
0
  } else {
540
0
    value = NULL;
541
0
  }
542
0
  if (value) {
543
0
    if (zend_uv.html_errors) {
544
0
      zend_printf("<font style=\"color: %s\">%s</font>", value, value);
545
0
    } else {
546
0
      ZEND_PUTS(value);
547
0
    }
548
0
  } else {
549
0
    if (zend_uv.html_errors) {
550
0
      ZEND_PUTS(NO_VALUE_HTML);
551
0
    } else {
552
0
      ZEND_PUTS(NO_VALUE_PLAINTEXT);
553
0
    }
554
0
  }
555
0
}
556
/* }}} */
557
558
ZEND_INI_DISP(display_link_numbers) /* {{{ */
559
0
{
560
0
  char *value;
561
562
0
  if (type == ZEND_INI_DISPLAY_ORIG && ini_entry->modified) {
563
0
    value = ZSTR_VAL(ini_entry->orig_value);
564
0
  } else if (ini_entry->value) {
565
0
    value = ZSTR_VAL(ini_entry->value);
566
0
  } else {
567
0
    value = NULL;
568
0
  }
569
570
0
  if (value) {
571
0
    if (atoi(value) == -1) {
572
0
      ZEND_PUTS("Unlimited");
573
0
    } else {
574
0
      zend_printf("%s", value);
575
0
    }
576
0
  }
577
0
}
578
/* }}} */
579
580
/* Standard message handlers */
581
ZEND_API ZEND_INI_MH(OnUpdateBool) /* {{{ */
582
113k
{
583
113k
  zend_bool *p = (zend_bool *) ZEND_INI_GET_ADDR();
584
113k
  *p = zend_ini_parse_bool(new_value);
585
113k
  return SUCCESS;
586
113k
}
587
/* }}} */
588
589
ZEND_API ZEND_INI_MH(OnUpdateLong) /* {{{ */
590
58.3k
{
591
58.3k
  zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
592
58.3k
  *p = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
593
58.3k
  return SUCCESS;
594
58.3k
}
595
/* }}} */
596
597
ZEND_API ZEND_INI_MH(OnUpdateLongGEZero) /* {{{ */
598
7.29k
{
599
7.29k
  zend_long tmp = zend_atol(ZSTR_VAL(new_value), ZSTR_LEN(new_value));
600
7.29k
  if (tmp < 0) {
601
0
    return FAILURE;
602
0
  }
603
604
7.29k
  zend_long *p = (zend_long *) ZEND_INI_GET_ADDR();
605
7.29k
  *p = tmp;
606
607
7.29k
  return SUCCESS;
608
7.29k
}
609
/* }}} */
610
611
ZEND_API ZEND_INI_MH(OnUpdateReal) /* {{{ */
612
0
{
613
0
  double *p = (double *) ZEND_INI_GET_ADDR();
614
0
  *p = zend_strtod(ZSTR_VAL(new_value), NULL);
615
0
  return SUCCESS;
616
0
}
617
/* }}} */
618
619
ZEND_API ZEND_INI_MH(OnUpdateString) /* {{{ */
620
105k
{
621
105k
  char **p = (char **) ZEND_INI_GET_ADDR();
622
47.3k
  *p = new_value ? ZSTR_VAL(new_value) : NULL;
623
105k
  return SUCCESS;
624
105k
}
625
/* }}} */
626
627
ZEND_API ZEND_INI_MH(OnUpdateStringUnempty) /* {{{ */
628
29.1k
{
629
29.1k
  if (new_value && !ZSTR_VAL(new_value)[0]) {
630
0
    return FAILURE;
631
0
  }
632
633
29.1k
  char **p = (char **) ZEND_INI_GET_ADDR();
634
18.2k
  *p = new_value ? ZSTR_VAL(new_value) : NULL;
635
29.1k
  return SUCCESS;
636
29.1k
}
637
/* }}} */