mirror of
https://github.com/apache/nuttx.git
synced 2026-06-01 16:59:28 +08:00
strftime(): Need null-termination on generated string. From Max Holtzberg
This commit is contained in:
@@ -6208,4 +6208,6 @@
|
|||||||
From Ken Pettit (2013-12-12)
|
From Ken Pettit (2013-12-12)
|
||||||
* arch/arm/src/a1x/chip/a1x_timer.h: Timer register bit definitions
|
* arch/arm/src/a1x/chip/a1x_timer.h: Timer register bit definitions
|
||||||
(incomplete on initial check-in) (2013-12-12).
|
(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
|
* 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>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* 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;
|
chleft -= len;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Append terminating null byte (if there is space for it) */
|
||||||
|
|
||||||
|
if (chleft > 0)
|
||||||
|
{
|
||||||
|
*dest = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
return max - chleft;
|
return max - chleft;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user