summaryrefslogtreecommitdiff
path: root/xgpsspeed.c
diff options
context:
space:
mode:
authorChris Kuethe <chris.kuethe@gmail.com>2006-08-19 05:30:49 +0000
committerChris Kuethe <chris.kuethe@gmail.com>2006-08-19 05:30:49 +0000
commit409d42666cb5b94cbe0bcbd7cc2246032379f880 (patch)
tree300679f0ea3c1e9a5f9f94b2148db76a77a8533f /xgpsspeed.c
parent2a488def273905cb325ea99ec61af4bbdd5cc8a1 (diff)
downloadgpsd-409d42666cb5b94cbe0bcbd7cc2246032379f880.tar.gz
String safety, courtesy of snprintf, strlcat and strlcpy.
GPSD is now free from the often-misused strcat, strcpy and sprintf. Future code should not use unbounded string functions. Glibc users, please verify that the integrated strlcat and strlcpy are correctly linked in.
Diffstat (limited to 'xgpsspeed.c')
-rw-r--r--xgpsspeed.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/xgpsspeed.c b/xgpsspeed.c
index 377bf4aa..a417a161 100644
--- a/xgpsspeed.c
+++ b/xgpsspeed.c
@@ -174,16 +174,18 @@ int main(int argc, char **argv)
gps_set_raw_hook(gpsdata, update_display);
if (device) {
- char *channelcmd = (char *)malloc(strlen(device)+3);
+ char *channelcmd;
+ size_t l;
+ l = strlen(device)+4;
- if (channelcmd) {
- /*@i1@*/(void)strcpy(channelcmd, "F=");
- (void)strcpy(channelcmd+2, device);
+ if ((channelcmd = (char *)malloc(l)) != NULL){
+ /*@i1@*/(void)strlcpy(channelcmd, "F=", l);
+ (void)strlcpy(channelcmd+2, device, l);
(void)gps_query(gpsdata, channelcmd);
(void)free(channelcmd);
}
}
-
+
(void)gps_query(gpsdata, "w+x\n");
(void)XtAppMainLoop(app);