Snap for 7224597 from c7838c5a5cb9a7a1dea2a5791f7f8028cf97d118 to sdk-release

Change-Id: Ic6f468b5621bb7c8ce924e522f36e6a637674b47
diff --git a/secure_element/1.0/GtoService.cpp b/secure_element/1.0/GtoService.cpp
index 9de5db6..897a004 100644
--- a/secure_element/1.0/GtoService.cpp
+++ b/secure_element/1.0/GtoService.cpp
@@ -26,7 +26,7 @@
 using android::status_t;
 
 int main() {
-  ALOGD("Thales Secure Element HAL for eSE1 Service 1.3.0 is starting. libse-gto v1.12");
+  ALOGD("Thales Secure Element HAL for eSE1 Service 1.4.0 is starting. libse-gto v1.13");
   sp<ISecureElement> se_service = new SecureElement("eSE1");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE1");
diff --git a/secure_element/1.0/GtoService_ese2.cpp b/secure_element/1.0/GtoService_ese2.cpp
index dac6ef7..2fc55cb 100644
--- a/secure_element/1.0/GtoService_ese2.cpp
+++ b/secure_element/1.0/GtoService_ese2.cpp
@@ -26,7 +26,7 @@
 using android::status_t;
 
 int main() {
-  ALOGD("Thales Secure Element HAL for eSE2 Service 1.3.0 is starting. libse-gto v1.12");
+  ALOGD("Thales Secure Element HAL for eSE2 Service 1.4.0 is starting. libse-gto v1.13");
   sp<ISecureElement> se_service = new SecureElement("eSE2");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE2");
diff --git a/secure_element/1.0/esehal/src/log.c b/secure_element/1.0/esehal/src/log.c
index 45deb6c..b6221cf 100644
--- a/secure_element/1.0/esehal/src/log.c
+++ b/secure_element/1.0/esehal/src/log.c
@@ -66,10 +66,12 @@
     if (k >= BUFSIZE)
         k = BUFSIZE - 1;
     buf    = ctx->log_buf;
-    buf[k] = '\000';
-    if ((buf[k - 1] == '\n') || (k == (BUFSIZE - 1))) {
-        k = 0;
-        ctx->log_fn(ctx, buf);
+    if (k >= 0) {
+        buf[k] = '\000';
+        if ((k > 0 && (buf[k - 1] == '\n')) || (k == (BUFSIZE - 1))) {
+            k = 0;
+            ctx->log_fn(ctx, buf);
+        }
     }
 }
 
diff --git a/secure_element/1.1/GtoService.cpp b/secure_element/1.1/GtoService.cpp
index c364309..a1157b7 100644
--- a/secure_element/1.1/GtoService.cpp
+++ b/secure_element/1.1/GtoService.cpp
@@ -27,7 +27,7 @@
 
 int main() {
   ALOGD("android::hardware::secure_element::V1_1 is starting.");
-  ALOGD("Thales Secure Element HAL for eSE2 Service 1.3.0 is starting. libse-gto v1.12");
+  ALOGD("Thales Secure Element HAL for eSE2 Service 1.4.0 is starting. libse-gto v1.13");
   sp<ISecureElement> se_service = new SecureElement("eSE1");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE1");
diff --git a/secure_element/1.1/GtoService_ese2.cpp b/secure_element/1.1/GtoService_ese2.cpp
index a699528..6f0efdf 100644
--- a/secure_element/1.1/GtoService_ese2.cpp
+++ b/secure_element/1.1/GtoService_ese2.cpp
@@ -27,7 +27,7 @@
 
 int main() {
   ALOGD("android::hardware::secure_element::V1_1 is starting.");
-  ALOGD("Thales Secure Element HAL for eSE2 Service 1.3.0 is starting. libse-gto v1.12");
+  ALOGD("Thales Secure Element HAL for eSE2 Service 1.4.0 is starting. libse-gto v1.13");
   sp<ISecureElement> se_service = new SecureElement("eSE2");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE2");
diff --git a/secure_element/1.2/GtoService.cpp b/secure_element/1.2/GtoService.cpp
index c7b2309..69cc3f4 100644
--- a/secure_element/1.2/GtoService.cpp
+++ b/secure_element/1.2/GtoService.cpp
@@ -27,7 +27,7 @@
 
 int main() {
   ALOGD("android::hardware::secure_element::V1_2 is starting.");
-  ALOGD("Thales Secure Element HAL for eSE1 Service 1.3.0 is starting. libse-gto v1.12");
+  ALOGD("Thales Secure Element HAL for eSE1 Service 1.4.0 is starting. libse-gto v1.13");
   sp<ISecureElement> se_service = new SecureElement("eSE1");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE1");
diff --git a/secure_element/1.2/GtoService_ese2.cpp b/secure_element/1.2/GtoService_ese2.cpp
index b6e6fc5..d718d8a 100644
--- a/secure_element/1.2/GtoService_ese2.cpp
+++ b/secure_element/1.2/GtoService_ese2.cpp
@@ -27,7 +27,7 @@
 
 int main() {
   ALOGD("android::hardware::secure_element::V1_2 is starting.");
-  ALOGD("Thales Secure Element HAL for eSE2 Service 1.3.0 is starting. libse-gto v1.12");
+  ALOGD("Thales Secure Element HAL for eSE2 Service 1.4.0 is starting. libse-gto v1.13");
   sp<ISecureElement> se_service = new SecureElement("eSE2");
   configureRpcThreadpool(1, true);
   status_t status = se_service->registerAsService("eSE2");