[Archive] Replaced localtime() with localtime_r().
authorPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 11 Jun 2015 09:23:22 +0000 (11:23 +0200)
committerPawel Andruszkiewicz <p.andruszkie@samsung.com>
Thu, 11 Jun 2015 09:23:22 +0000 (11:23 +0200)
Prevent CID: 446658, 446423

[Verification] TCT pass rate: 100%

Change-Id: Iae5221881b56c23f93d507cec37de1fbca860c09
Signed-off-by: Pawel Andruszkiewicz <p.andruszkie@samsung.com>
src/archive/zip.cc
src/archive/zip_add_request.cc

index 51d4a92..251c2dd 100755 (executable)
@@ -55,14 +55,15 @@ void Zip::generateZipFileInfo(const std::string& filename, zip_fileinfo& out_zi)
         }
     }
 
-    struct tm* filedate = localtime(&tm_t);
-    if(filedate) {
-        out_zi.tmz_date.tm_sec  = filedate->tm_sec;
-        out_zi.tmz_date.tm_min  = filedate->tm_min;
-        out_zi.tmz_date.tm_hour = filedate->tm_hour;
-        out_zi.tmz_date.tm_mday = filedate->tm_mday;
-        out_zi.tmz_date.tm_mon  = filedate->tm_mon ;
-        out_zi.tmz_date.tm_year = filedate->tm_year;
+    struct tm filedate = {0};
+    tzset();
+    if (nullptr != localtime_r(&tm_t, &filedate)) {
+        out_zi.tmz_date.tm_sec  = filedate.tm_sec;
+        out_zi.tmz_date.tm_min  = filedate.tm_min;
+        out_zi.tmz_date.tm_hour = filedate.tm_hour;
+        out_zi.tmz_date.tm_mday = filedate.tm_mday;
+        out_zi.tmz_date.tm_mon  = filedate.tm_mon ;
+        out_zi.tmz_date.tm_year = filedate.tm_year;
     }
 }
 
index ba7b5ef..6a5e570 100755 (executable)
@@ -254,14 +254,15 @@ PlatformResult ZipAddRequest::addEmptyDirectoryToZipArchive(std::string name_in_
     // Since this directory does not exist we will set current time
     //
     time_t current_time = time(NULL);
-    struct tm* current_time_tm = localtime(&current_time);
-    if(current_time_tm) {
-        new_dir_info.tmz_date.tm_sec  = current_time_tm->tm_sec;
-        new_dir_info.tmz_date.tm_min  = current_time_tm->tm_min;
-        new_dir_info.tmz_date.tm_hour = current_time_tm->tm_hour;
-        new_dir_info.tmz_date.tm_mday = current_time_tm->tm_mday;
-        new_dir_info.tmz_date.tm_mon  = current_time_tm->tm_mon ;
-        new_dir_info.tmz_date.tm_year = current_time_tm->tm_year;
+    struct tm current_time_tm = {0};
+    tzset();
+    if (nullptr != localtime_r(&current_time, &current_time_tm)) {
+        new_dir_info.tmz_date.tm_sec  = current_time_tm.tm_sec;
+        new_dir_info.tmz_date.tm_min  = current_time_tm.tm_min;
+        new_dir_info.tmz_date.tm_hour = current_time_tm.tm_hour;
+        new_dir_info.tmz_date.tm_mday = current_time_tm.tm_mday;
+        new_dir_info.tmz_date.tm_mon  = current_time_tm.tm_mon ;
+        new_dir_info.tmz_date.tm_year = current_time_tm.tm_year;
     }
 
     int err = zipOpenNewFileInZip3(m_owner.m_zip, name_in_zip.c_str(), &new_dir_info,