Skip to content

Drop support for printf p modifier #7159

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 8 additions & 14 deletions main/snprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -738,9 +738,15 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
#endif
break;
case 'p':
fmt++;
modifier = LM_PHP_INT_T;
{
char __next = *(fmt+1);
if ('d' == __next || 'u' == __next || 'x' == __next || 'o' == __next) {
zend_error_noreturn(E_CORE_ERROR,
"printf \"p\" modifier is no longer supported, use ZEND_LONG_FMT");
}
modifier = LM_STD;
break;
}
case 'h':
fmt++;
if (*fmt == 'h') {
Expand Down Expand Up @@ -803,9 +809,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
i_num = (wide_int) va_arg(ap, zend_ulong);
break;
}
/*
* The rest also applies to other integer formats, so fall
Expand Down Expand Up @@ -849,9 +852,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
i_num = (wide_int) va_arg(ap, zend_long);
break;
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
Expand Down Expand Up @@ -898,9 +898,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
ui_num = (u_wide_int) va_arg(ap, zend_ulong);
break;
}
s = ap_php_conv_p2(ui_num, 3, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
Expand Down Expand Up @@ -940,9 +937,6 @@ static int format_converter(register buffy * odp, const char *fmt, va_list ap) /
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
ui_num = (u_wide_int) va_arg(ap, zend_ulong);
break;
}
s = ap_php_conv_p2(ui_num, 4, *fmt, &num_buf[NUM_BUF_SIZE], &s_len);
FIX_PRECISION(adjust_precision, precision, s, s_len);
Expand Down
1 change: 0 additions & 1 deletion main/snprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,6 @@ typedef enum {
LM_SIZE_T,
LM_LONG,
LM_LONG_DOUBLE,
LM_PHP_INT_T
} length_modifier_e;

#ifdef PHP_WIN32
Expand Down
28 changes: 8 additions & 20 deletions main/spprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -338,16 +338,16 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
modifier = LM_SIZE_T;
#endif
break;
case 'p': {
char __next = *(fmt+1);
if ('d' == __next || 'u' == __next || 'x' == __next || 'o' == __next) {
fmt++;
modifier = LM_PHP_INT_T;
} else {
modifier = LM_STD;
}
case 'p':
{
char __next = *(fmt+1);
if ('d' == __next || 'u' == __next || 'x' == __next || 'o' == __next) {
zend_error_noreturn(E_CORE_ERROR,
"printf \"p\" modifier is no longer supported, use ZEND_LONG_FMT");
}
modifier = LM_STD;
break;
}
case 'h':
fmt++;
if (*fmt == 'h') {
Expand Down Expand Up @@ -410,9 +410,6 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
i_num = (wide_int) va_arg(ap, zend_ulong);
break;
}
/*
* The rest also applies to other integer formats, so fall
Expand Down Expand Up @@ -456,9 +453,6 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
i_num = (wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
i_num = (wide_int) va_arg(ap, zend_long);
break;
}
}
s = ap_php_conv_10(i_num, (*fmt) == 'u', &is_negative,
Expand Down Expand Up @@ -504,9 +498,6 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
ui_num = (u_wide_int) va_arg(ap, zend_ulong);
break;
}
s = ap_php_conv_p2(ui_num, 3, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
Expand Down Expand Up @@ -547,9 +538,6 @@ static void xbuf_format_converter(void *xbuf, bool is_char, const char *fmt, va_
ui_num = (u_wide_int) va_arg(ap, ptrdiff_t);
break;
#endif
case LM_PHP_INT_T:
ui_num = (u_wide_int) va_arg(ap, zend_ulong);
break;
}
s = ap_php_conv_p2(ui_num, 4, *fmt,
&num_buf[NUM_BUF_SIZE], &s_len);
Expand Down