gnss: properly terminate nmea-messages if they aren't already

Some legacy vendor blobs don't properly terminate the messages.
This fix shouldn't have any effect if the messages are already terminated properly.

Since Q this results in the following crash when using passthrough:

--------- beginning of crash
09-30 23:27:54.833   799  1971 F libc    : Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 1971 (Thread-5), pid 799 (system_server)
09-30 23:27:55.070  5387  5387 F DEBUG   : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
09-30 23:27:55.070  5387  5387 F DEBUG   : Build fingerprint: 'htc/himaulatt_na_gen_unlock/htc_himaulatt:7.0/NRD90M/894012.12:user/release-keys'
09-30 23:27:55.070  5387  5387 F DEBUG   : Revision: '0'
09-30 23:27:55.070  5387  5387 F DEBUG   : ABI: 'arm64'
09-30 23:27:55.072  5387  5387 F DEBUG   : Timestamp: 2019-09-30 23:27:55+0200
09-30 23:27:55.072  5387  5387 F DEBUG   : pid: 799, tid: 1971, name: Thread-5  >>> system_server <<<
09-30 23:27:55.072  5387  5387 F DEBUG   : uid: 1000
09-30 23:27:55.072  5387  5387 F DEBUG   : signal 6 (SIGABRT), code -1 (SI_QUEUE), fault addr --------
09-30 23:27:55.072  5387  5387 F DEBUG   : Abort message: 'Check failed: data[size] == '\0' '
09-30 23:27:55.072  5387  5387 F DEBUG   :     x0  0000000000000000  x1  00000000000007b3  x2  0000000000000006  x3  000000728f4129a0
09-30 23:27:55.072  5387  5387 F DEBUG   :     x4  000000728f4126dc  x5  000000728f4126dc  x6  000000728f4126dc  x7  0000000000000000
09-30 23:27:55.072  5387  5387 F DEBUG   :     x8  00000000000000f0  x9  00000073ddc594e0  x10 0000000000000000  x11 0000000000000001
09-30 23:27:55.072  5387  5387 F DEBUG   :     x12 000000000d473178  x13 0000000000030000  x14 0000000000000008  x15 0031a65e46424655
09-30 23:27:55.072  5387  5387 F DEBUG   :     x16 00000073ddd278c0  x17 00000073ddd050f0  x18 00000073504afb80  x19 00000000000000ac
09-30 23:27:55.072  5387  5387 F DEBUG   :     x20 000000000000031f  x21 00000000000000b2  x22 00000000000007b3  x23 00000000ffffffff
09-30 23:27:55.072  5387  5387 F DEBUG   :     x24 000000728f413020  x25 0000000000000012  x26 0000000000000005  x27 000000735b8b0555
09-30 23:27:55.072  5387  5387 F DEBUG   :     x28 000000735b8d2012  x29 000000728f412a50
09-30 23:27:55.072  5387  5387 F DEBUG   :     sp  000000728f412980  lr  00000073ddcb80f0  pc  00000073ddcb8120
09-30 23:27:55.086  5387  5387 F DEBUG   :
09-30 23:27:55.086  5387  5387 F DEBUG   : backtrace:
09-30 23:27:55.087  5387  5387 F DEBUG   :       #00 pc 0000000000083120  /apex/com.android.runtime/lib64/bionic/libc.so (abort+176) (BuildId: b6e9b6229a138e2c7f4b75aadd5bd4e3)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #01 pc 00000000004b9234  /apex/com.android.runtime/lib64/libart.so (art::Runtime::Abort(char const*)+2172) (BuildId: 6220a597f216ded8aaaff768acbe9ef2)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #02 pc 000000000000c650  /system/lib64/libbase.so (android::base::LogMessage::~LogMessage()+608) (BuildId: 74e39b9e4bda61561a36377476803040)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #03 pc 000000000005211c  /system/lib64/libhidlbase.so (android::hardware::hidl_string::setToExternal(char const*, unsigned long)+348) (BuildId: 853d949ae1ed18388f66e31a7371e891)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #04 pc 0000000000011994  /vendor/lib64/hw/android.hardware.gnss@1.0-impl.so (android::hardware::gnss::V1_0::implementation::Gnss::nmeaCb(long, char const*, int)+84) (BuildId: 0237c57debce669c40e3d4e825502539)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #05 pc 000000000000c12c  /vendor/lib64/libloc_eng.so (LocEngReportNmea::proc() const+112) (BuildId: d03867282560d37a14cb51101888b74a)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #06 pc 0000000000007e60  /vendor/lib64/libgps.utils.so (MsgTask::run()+152) (BuildId: ebea65e623475dac5b17351ca3054f6b)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #07 pc 0000000000007788  /vendor/lib64/libgps.utils.so (LocThreadDelegate::threadMain(void*)+68) (BuildId: ebea65e623475dac5b17351ca3054f6b)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #08 pc 000000000001002c  /vendor/lib64/hw/android.hardware.gnss@1.0-impl.so (threadFunc(void*)+12) (BuildId: 0237c57debce669c40e3d4e825502539)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #09 pc 00000000000e43f4  /apex/com.android.runtime/lib64/bionic/libc.so (__pthread_start(void*)+36) (BuildId: b6e9b6229a138e2c7f4b75aadd5bd4e3)
09-30 23:27:55.087  5387  5387 F DEBUG   :       #10 pc 0000000000084d18  /apex/com.android.runtime/lib64/bionic/libc.so (__start_thread+64) (BuildId: b6e9b6229a138e2c7f4b75aadd5bd4e3)

When using binderized HAL it fails earlier already with:
10-01 15:31:09.691 804 2421 E HidlSupport: Received unterminated hidl_string buffer.
10-01 15:31:09.691 472 1982 E GnssHAL_GnssInterface: nmeaCb: Unable to invoke callback

Change-Id: I8931ec4c38d7f5de3a5c9605040ee27cbbdaaaea
Signed-off-by: Pranav Vashi <neobuddy89@gmail.com>
1 file changed