strftime: fix underlying format string in %z format

Submitted by Daniel Sabogal on June 11, 2018, 5:15 p.m.

Details

Message ID 20180611171515.3920-1-dsabogalcc@gmail.com
State New
Series "strftime: fix underlying format string in %z format"
Headers show

Commit Message

Daniel Sabogal June 11, 2018, 5:15 p.m.
the expression (tm->__tm_gmtoff)/3600 has type long. use %+.2ld instead.
---
 src/time/strftime.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/src/time/strftime.c b/src/time/strftime.c
index 708875ee..0a256970 100644
--- a/src/time/strftime.c
+++ b/src/time/strftime.c
@@ -181,7 +181,7 @@  const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *
 			*l = 0;
 			return "";
 		}
-		*l = snprintf(*s, sizeof *s, "%+.2d%.2d",
+		*l = snprintf(*s, sizeof *s, "%+.2ld%.2d",
 			(tm->__tm_gmtoff)/3600,
 			abs(tm->__tm_gmtoff%3600)/60);
 		return *s;

Comments

Rich Felker June 26, 2018, 8:45 p.m.
On Mon, Jun 11, 2018 at 01:15:15PM -0400, Daniel Sabogal wrote:
> the expression (tm->__tm_gmtoff)/3600 has type long. use %+.2ld instead.
> ---
>  src/time/strftime.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/src/time/strftime.c b/src/time/strftime.c
> index 708875ee..0a256970 100644
> --- a/src/time/strftime.c
> +++ b/src/time/strftime.c
> @@ -181,7 +181,7 @@ const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm *
>  			*l = 0;
>  			return "";
>  		}
> -		*l = snprintf(*s, sizeof *s, "%+.2d%.2d",
> +		*l = snprintf(*s, sizeof *s, "%+.2ld%.2d",
>  			(tm->__tm_gmtoff)/3600,
>  			abs(tm->__tm_gmtoff%3600)/60);
>  		return *s;
> -- 
> 2.17.1

Thanks. Applied.

Rich