*
* 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
*
* 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
*
* 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;
}
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);
}
*
* 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
*
* 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