strftime(): Need null-termination on generated string. From Max Holtzberg
This commit is contained in:
parent
c0367fcc0a
commit
2fac3de49e
|
@ -6208,4 +6208,6 @@
|
|||
From Ken Pettit (2013-12-12)
|
||||
* arch/arm/src/a1x/chip/a1x_timer.h: Timer register bit definitions
|
||||
(incomplete on initial check-in) (2013-12-12).
|
||||
* lbc/time/lib_strftime.c: Need null-termination on the the string
|
||||
generated by strftime(). From Max Holtzberg (2013-12-12).
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/****************************************************************************
|
||||
* libc/time/lib_strftime.c
|
||||
*
|
||||
* Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved.
|
||||
* Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
|
@ -394,5 +394,12 @@ size_t strftime(char *s, size_t max, const char *format, const struct tm *tm)
|
|||
chleft -= len;
|
||||
}
|
||||
|
||||
/* Append terminating null byte (if there is space for it) */
|
||||
|
||||
if (chleft > 0)
|
||||
{
|
||||
*dest = '\0';
|
||||
}
|
||||
|
||||
return max - chleft;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue