Skip to content

Commit

Permalink
Merge pull request #3698 from telefonicaid/hotfix/gmtime_thread_safe
Browse files Browse the repository at this point in the history
FIX gmtime() -> gmtime_r() (release/2.4.0)
  • Loading branch information
mrutid authored Sep 23, 2020
2 parents 60659d1 + 8fd5644 commit f416ddb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
[![SOF support badge](https://nexus.lab.fiware.org/repository/raw/public/badges/stackoverflow/orion.svg)](http://stackoverflow.com/questions/tagged/fiware-orion)
[![NGSI v2](https://nexus.lab.fiware.org/repository/raw/public/badges/specifications/ngsiv2.svg)](http://fiware-ges.github.io/orion/api/v2/stable/)
<br>
[![Documentation badge](https://img.shields.io/readthedocs/fiware-orion/2.4.0.svg)](https://fiware-orion.rtfd.io/en/2.4.0/)
[![Documentation badge](https://img.shields.io/readthedocs/fiware-orion/2.4.1.svg)](https://fiware-orion.rtfd.io/en/2.4.1/)
[![Build badge](https://img.shields.io/travis/telefonicaid/fiware-orion.svg)](https://travis-ci.org/telefonicaid/fiware-orion/)
![Status](https://nexus.lab.fiware.org/static/badges/statuses/orion.svg)

Expand Down
3 changes: 3 additions & 0 deletions rpm/SPECS/contextBroker.spec
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ if [ "$1" == "0" ]; then
fi

%changelog
* Wed Sep 23 2020 Fermin Galan <[email protected]> 2.4.1-1
- Fix: potencial race condition related with DateTime attributes due to the usage of thread unsafe functions

* Tue Mar 31 2020 Fermin Galan <[email protected]> 2.4.0-1
- Add: TextUnrestricted attribute type to avoid forbidden chars checking (#3550)
- Add: notification flow control on update (#3568)
Expand Down
2 changes: 1 addition & 1 deletion src/app/contextBroker/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@



#define ORION_VERSION "2.4.0"
#define ORION_VERSION "2.4.1"

#endif // SRC_APP_CONTEXTBROKER_VERSION_H_
2 changes: 1 addition & 1 deletion src/lib/common/defaultValues.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@
*
* API Documentation - The link to the the GEri documentation, either in the gh-pages (.github.io/) inside the fiware organization in GitHub or ReadTheDocs manual.
*/
#define API_DOC "https://fiware-orion.rtfd.io/en/2.4.0/"
#define API_DOC "https://fiware-orion.rtfd.io/en/2.4.1/"

#endif // SRC_LIB_COMMON_DEFAULTVALUES_H_
10 changes: 6 additions & 4 deletions src/lib/common/string.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1003,17 +1003,19 @@ std::string double2string(double f)
*
* isodate2str -
*
* FIXME P6: change implementation to use gmtime_r
*
*/
std::string isodate2str(long long timestamp)
{
// 80 bytes is enough to store any ISO8601 string safely
// We use gmtime() to get UTC strings, otherwise we would use localtime()
// We use gmtime_r() to get UTC strings, otherwise we would use localtime()
// Date pattern: 1970-04-26T17:46:40.00Z
char buffer[80];

// Unused, but needed to fullfill gmtime_r() signature
struct tm tmP;

time_t rawtime = (time_t) timestamp;
strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S.00Z", gmtime(&rawtime));
strftime(buffer, sizeof(buffer), "%Y-%m-%dT%H:%M:%S.00Z", gmtime_r(&rawtime, &tmP));
return std::string(buffer);
}

Expand Down

0 comments on commit f416ddb

Please sign in to comment.