diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2011-03-29 06:41:09 -0400 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2011-03-29 06:41:09 -0400 |
commit | 3ef1d9ecbef54ba5e4e6a8167a8dd5c5723aa94f (patch) | |
tree | b7dcab4eb669ca6fe3fc18bd672bc53e5a3d2c57 /net_ntrip.c | |
parent | c48d0caf13ce030166fedad354e4732584584f50 (diff) | |
download | gpsd-3ef1d9ecbef54ba5e4e6a8167a8dd5c5723aa94f.tar.gz |
Magic-number and strncpy elimination. All regression tests pass
Diffstat (limited to 'net_ntrip.c')
-rw-r--r-- | net_ntrip.c | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/net_ntrip.c b/net_ntrip.c index 53285caa..27b1de15 100644 --- a/net_ntrip.c +++ b/net_ntrip.c @@ -74,7 +74,7 @@ static void ntrip_str_parse(char *str, size_t len, /* <mountpoint> */ if ((s = ntrip_field_iterate(str, NULL, eol))) - strncpy(hold->mountpoint, s, sizeof(hold->mountpoint) - 1); + (void)strlcpy(hold->mountpoint, s, sizeof(hold->mountpoint)); /* <identifier> */ s = ntrip_field_iterate(NULL, s, eol); /* <format> */ @@ -485,10 +485,18 @@ int ntrip_open(struct gps_device_t *device, char *caster) port = DEFAULT_RTCM_PORT; } - strncpy(device->ntrip.stream.mountpoint, stream, 101); /* magic numbers from struct definitions */ - strncpy(device->ntrip.stream.credentials, auth, 128); /* magic numbers from struct definitions */ - strncpy(device->ntrip.stream.url, url, 256); - strncpy(device->ntrip.stream.port, port, 32); + (void)strlcpy(device->ntrip.stream.mountpoint, + stream, + sizeof(device->ntrip.stream.mountpoint)); + (void)strlcpy(device->ntrip.stream.credentials, + auth, + sizeof(device->ntrip.stream.credentials)); + (void)strlcpy(device->ntrip.stream.url, + url, + sizeof(device->ntrip.stream.url)); + (void)strlcpy(device->ntrip.stream.port, + port, + sizeof(device->ntrip.stream.port)); ret = ntrip_stream_req_probe(&device->ntrip.stream); if (ret == -1) { |