From d24e836f200eb23826361a4822adc3817cb0be95 Mon Sep 17 00:00:00 2001 From: GetAway Date: Wed, 8 Jul 2020 20:49:35 +0200 Subject: [PATCH] controlapi.cpp: remove deprecated ftime(), use helpers Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/829b47c0f4f6196e2ec45eae6d9e8a54113cc0be Author: GetAway Date: 2020-07-08 (Wed, 08 Jul 2020) ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- src/nhttpd/tuxboxapi/controlapi.cpp | 20 +++++--------------- src/nhttpd/yhttpd_core/helper.h | 3 --- 2 files changed, 5 insertions(+), 18 deletions(-) diff --git a/src/nhttpd/tuxboxapi/controlapi.cpp b/src/nhttpd/tuxboxapi/controlapi.cpp index 1ff9f7d3f..6a3da2f62 100644 --- a/src/nhttpd/tuxboxapi/controlapi.cpp +++ b/src/nhttpd/tuxboxapi/controlapi.cpp @@ -641,19 +641,13 @@ void CControlAPI::RCCGI(CyhookHandler *hh) //----------------------------------------------------------------------------- // Get actual Date -// security: strftime has buffer-overflow limit. ok! //----------------------------------------------------------------------------- void CControlAPI::GetDateCGI(CyhookHandler *hh) { if (hh->ParamList.empty()) { - //paramlos - char *timestr = new char[50]; - struct timeb tm; - ftime(&tm); - strftime(timestr, 20, "%d.%m.%Y\n", localtime(&tm.time) ); + std::string timestr = getNowTimeStr("%d.%m.%Y\n"); hh->Write(timestr); - delete[] timestr; } else hh->SendError(); @@ -661,23 +655,19 @@ void CControlAPI::GetDateCGI(CyhookHandler *hh) //----------------------------------------------------------------------------- // Get actual Time -// security: strftime has buffer-overflow limit. ok! //----------------------------------------------------------------------------- void CControlAPI::GetTimeCGI(CyhookHandler *hh) { - time_t now = time(NULL); - if (hh->ParamList.empty()) { - //paramlos - char *timestr = new char[50]; - struct tm *tm = localtime(&now); - strftime(timestr, 20, "%H:%M:%S\n", tm ); + std::string timestr = getNowTimeStr("%H:%M:%S\n"); hh->Write(timestr); - delete[] timestr; } else if (hh->ParamList["1"].compare("rawtime") == 0) + { + time_t now = time(0); hh->printf("%ld\n",now); + } else hh->SendError(); } diff --git a/src/nhttpd/yhttpd_core/helper.h b/src/nhttpd/yhttpd_core/helper.h index d322c04ad..fd04c3247 100644 --- a/src/nhttpd/yhttpd_core/helper.h +++ b/src/nhttpd/yhttpd_core/helper.h @@ -5,9 +5,6 @@ #ifndef __yhttpd_helper_h__ #define __yhttpd_helper_h__ -// c -#include -#include // c++ #include #include