From 7deff90a051e7960617c53ebb0478bf32faa4e80 Mon Sep 17 00:00:00 2001 From: Sangdok Mo Date: Fri, 14 Jul 2017 16:07:41 +0900 Subject: [PATCH] removed wrong contact points and added some authors, fixed misuse of strncpy and strncat Change-Id: If88b27b4c57eb9ff227565779eb881e9f4e02c73 Signed-off-by: Sangdok Mo --- AUTHORS | 2 ++ gps-plugin/include/gps_plugin_debug.h | 3 --- gps-plugin/include/nmea_parser.h | 3 --- gps-plugin/include/setting.h | 3 --- gps-plugin/src/gps_plugin_replay.c | 20 ++++++++++++-------- gps-plugin/src/nmea_parser.c | 3 --- gps-plugin/src/setting.c | 3 --- 7 files changed, 14 insertions(+), 23 deletions(-) diff --git a/AUTHORS b/AUTHORS index a879250..6ccf5cc 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,3 +1,5 @@ +Kyoungjun Sung +Seechan Kim Youngae Kang Minjune Kim Genie Kim diff --git a/gps-plugin/include/gps_plugin_debug.h b/gps-plugin/include/gps_plugin_debug.h index e74a02d..790b08b 100644 --- a/gps-plugin/include/gps_plugin_debug.h +++ b/gps-plugin/include/gps_plugin_debug.h @@ -3,9 +3,6 @@ * * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Minjune Kim - * Genie Kim - * * 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 diff --git a/gps-plugin/include/nmea_parser.h b/gps-plugin/include/nmea_parser.h index dd2b2c8..73d5bef 100644 --- a/gps-plugin/include/nmea_parser.h +++ b/gps-plugin/include/nmea_parser.h @@ -3,9 +3,6 @@ * * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Minjune Kim - * Genie Kim - * * 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 diff --git a/gps-plugin/include/setting.h b/gps-plugin/include/setting.h index 4436c31..a0727e6 100644 --- a/gps-plugin/include/setting.h +++ b/gps-plugin/include/setting.h @@ -3,9 +3,6 @@ * * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Minjune Kim - * Genie Kim - * * 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 diff --git a/gps-plugin/src/gps_plugin_replay.c b/gps-plugin/src/gps_plugin_replay.c index 61eaa5a..7e47745 100644 --- a/gps-plugin/src/gps_plugin_replay.c +++ b/gps-plugin/src/gps_plugin_replay.c @@ -3,9 +3,6 @@ * * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Minjune Kim - * Genie Kim - * * 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 @@ -39,6 +36,11 @@ #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); } diff --git a/gps-plugin/src/nmea_parser.c b/gps-plugin/src/nmea_parser.c index 6beafc5..b976bbc 100644 --- a/gps-plugin/src/nmea_parser.c +++ b/gps-plugin/src/nmea_parser.c @@ -3,9 +3,6 @@ * * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Minjune Kim - * Genie Kim - * * 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 diff --git a/gps-plugin/src/setting.c b/gps-plugin/src/setting.c index 135fa57..7726a03 100644 --- a/gps-plugin/src/setting.c +++ b/gps-plugin/src/setting.c @@ -3,9 +3,6 @@ * * Copyright (c) 2011-2013 Samsung Electronics Co., Ltd. All rights reserved. * - * Contact: Youngae Kang , Minjune Kim - * Genie Kim - * * 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 -- 2.34.1