diff options
author | Chris Kuethe <chris.kuethe@gmail.com> | 2009-01-06 15:59:27 +0000 |
---|---|---|
committer | Chris Kuethe <chris.kuethe@gmail.com> | 2009-01-06 15:59:27 +0000 |
commit | bfd84c7d21187d63ea9b659c3ecf2ecef5661c4a (patch) | |
tree | 263321f2494b752068d9d3a54aa43ee94e1f8ad4 /sirfflash.c | |
parent | 0214235e416860e9cfc7022edae256b8580bdd45 (diff) | |
download | gpsd-bfd84c7d21187d63ea9b659c3ecf2ecef5661c4a.tar.gz |
fix use of unbounded string functions and format warnings
Diffstat (limited to 'sirfflash.c')
-rw-r--r-- | sirfflash.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/sirfflash.c b/sirfflash.c index 1387de7c..52b33eeb 100644 --- a/sirfflash.c +++ b/sirfflash.c @@ -86,6 +86,7 @@ nmea_lowlevel_send(int fd, const char *fmt, ... ) { char buf[BUFSIZ]; va_list ap; + size_t l; va_start(ap, fmt) ; #ifdef HAVE_VSNPRINTF @@ -94,9 +95,10 @@ nmea_lowlevel_send(int fd, const char *fmt, ... ) vsprintf(buf + strlen(buf), fmt, ap); #endif va_end(ap); - strcat(buf, "*"); + strncat(buf, "*", 1); nmea_add_checksum(buf + 1); - if (write(fd, buf, strlen(buf)) != strlen(buf)) + l = strlen(buf); + if (write(fd, buf, l) != (ssize_t)l) fputs("sirfflash: write to device failed\n", stderr); } @@ -105,7 +107,7 @@ sirfSendUpdateCmd(int pfd){ bool status; /*@ +charint @*/ static unsigned char msg[] = { - 0xa0,0xa2, /* header */ + 0xa0,0xa2, /* header */ 0x00,0x01, /* message length */ 0x94, /* 0x94: firmware update */ 0x00,0x00, /* checksum */ @@ -245,7 +247,7 @@ static int sirfProbe(int fd, char **version) if (status == -1) return -1; } - gpsd_report(LOG_PROG, "%d bytes = %s\n", len, gpsd_hexdump(buf, (size_t)len)); + gpsd_report(LOG_PROG, "%ld bytes = %s\n", len, gpsd_hexdump(buf, (size_t)len)); *version = strdup(buf); return 0; } else { |