removed wrong contact points and added some authors, 92/139292/8
authorSangdok Mo <sd.mo@samsung.com>
Fri, 14 Jul 2017 07:07:41 +0000 (16:07 +0900)
committerSangdok Mo <sd.mo@samsung.com>
Fri, 21 Jul 2017 04:00:51 +0000 (13:00 +0900)
fixed misuse of strncpy and strncat

Change-Id: If88b27b4c57eb9ff227565779eb881e9f4e02c73
Signed-off-by: Sangdok Mo <sd.mo@samsung.com>
AUTHORS
gps-plugin/include/gps_plugin_debug.h
gps-plugin/include/nmea_parser.h
gps-plugin/include/setting.h
gps-plugin/src/gps_plugin_replay.c
gps-plugin/src/nmea_parser.c
gps-plugin/src/setting.c

diff --git a/AUTHORS b/AUTHORS
index a87925003d91fe8523498db982cfdd4949a66bba..6ccf5cc2b2ec8c252f67b74e914bd89bc90bfe63 100644 (file)
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,3 +1,5 @@
+Kyoungjun Sung <kj7.sung@samsung.com>
+Seechan Kim <cbible.kim@samsung.com>
 Youngae Kang <youngae.kang@samsung.com>
 Minjune Kim <sena06.kim@samsung.com>
 Genie Kim <daejins.kim@samsung.com>
index e74a02d3e3bd7e61a65573d4245cbba3870ec92b..790b08b6e213e99f28ddeb517c90482061d6a909 100644 (file)
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *                     Genie Kim <daejins.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
index dd2b2c865acb1598cccc5730d4191ca47489bcce..73d5bef0702d943010cd408cf813e27a47ebccf1 100644 (file)
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *                     Genie Kim <daejins.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
index 4436c31433ff6eded0bfaabadffb44bed7308729..a0727e696b6e6a1d12b2e14abfefaa167ddd4c60 100644 (file)
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *                     Genie Kim <daejins.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
index 61eaa5a8395bcf86bedec416a3201d97394ea76d..7e47745372ab3fab9f644b934b18c2055373be66 100644 (file)
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *                     Genie Kim <daejins.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
 #define REPLAY_NMEA_SET_SIZE           4096
 #define REPLAY_NMEA_SENTENCE_SIZE      128
 
+#define MIN(a,b) \
+   ({ __typeof__ (a) _a = (a); \
+       __typeof__ (b) _b = (b); \
+     _a < _b ? _a : _b; })
+
 
 gps_event_cb g_gps_event_cb = NULL;
 void *g_user_data = NULL;
@@ -299,26 +301,28 @@ gboolean gps_plugin_replay_read_nmea(replay_timeout *timer, char *nmea_data)
        }
 
        while (fgets(buf, REPLAY_NMEA_SENTENCE_SIZE, timer->fd) != NULL) {
+               size_t buf_len = strlen(buf);
                if (strncmp(buf, "$GPGGA", 6) == 0) {
                        ref++;
                        if (ref > 1) {
-                               fseek(timer->fd, -strlen(buf), SEEK_CUR);
+                               fseek(timer->fd, -buf_len, SEEK_CUR);
                                /* LOG_PLUGIN(DBG_LOW, "2nd GPGGA : stop to read nmea data"); */
                                ret = TRUE;
                                break;
                        } else if (ref == 1) {
                                /* LOG_PLUGIN(DBG_LOW, "1st GPGGA : start to read nmea data"); */
-                               strncpy(nmea_data, buf, strlen(buf) - 1);
+                               strncpy(nmea_data, buf, MIN(buf_len, REPLAY_NMEA_SET_SIZE - 1));
                        }
                } else {
-                       if (strlen(nmea_data) + strlen(buf) > REPLAY_NMEA_SET_SIZE) {
+                       size_t nmea_data_len = strlen(nmea_data);
+                       if ((nmea_data_len + buf_len) > (REPLAY_NMEA_SET_SIZE - 1)) {
                                LOG_PLUGIN(DBG_ERR, "read nmea data size is too long");
                                break;
                        } else {
-                               strncat(nmea_data, buf, strlen(buf));
+                               strncat(nmea_data, buf, REPLAY_NMEA_SET_SIZE - nmea_data_len - 1);
                        }
                }
-               timer->nmea_data->len = strlen(buf);
+               timer->nmea_data->len = buf_len;
                timer->nmea_data->data = buf;
                gps_plugin_replay_nmea_event(timer->nmea_data);
        }
index 6beafc5d515b08998dcbb78b18f5bfef287f59d9..b976bbcd5c14f9f371f74b8eafd9fff39c852887 100644 (file)
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *                     Genie Kim <daejins.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
index 135fa577c903db21626187fb7ba5a0309f121f06..7726a036741ba35b4d2533062b52f5a8f70d1cbb 100644 (file)
@@ -3,9 +3,6 @@
  *
  * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved.
  *
- * Contact: Youngae Kang <youngae.kang@samsung.com>, Minjune Kim <sena06.kim@samsung.com>
- *                     Genie Kim <daejins.kim@samsung.com>
- *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at