summaryrefslogtreecommitdiff
path: root/gps2udp.c
diff options
context:
space:
mode:
authorMichael Tatarinov <kukabu@gmail.com>2013-11-11 11:12:02 +0400
committerEric S. Raymond <esr@thyrsus.com>2013-11-11 06:57:33 -0500
commitededb9a805a290bf4eefc6cfb5c444a4e5f87425 (patch)
tree74771dc61266fb63dab2376554797edd4fb86078 /gps2udp.c
parent7fa23378f3c368b2a87f2655670076b2ea3c5188 (diff)
downloadgpsd-ededb9a805a290bf4eefc6cfb5c444a4e5f87425.tar.gz
Fix bug in array bounds and replace exit() with exit(EXIT_{SUCCESS,FAILURE}).
Signed-off-by: Eric S. Raymond <esr@thyrsus.com>
Diffstat (limited to 'gps2udp.c')
-rw-r--r--gps2udp.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/gps2udp.c b/gps2udp.c
index 9a4d0436..313ef36b 100644
--- a/gps2udp.c
+++ b/gps2udp.c
@@ -299,7 +299,7 @@ static ssize_t read_gpsd(char *message, size_t len)
break;
}
}
- message[ind] = '\0';
+ message[ind-1] = '\0';
(void)fprintf (stderr,"\n gps2udp: message too big [%s]\n", message);
return(-1);
}
@@ -393,12 +393,12 @@ int main(int argc, char **argv)
case 'v':
(void)fprintf(stderr, "%s: %s (revision %s)\n",
argv[0], VERSION, REVISION);
- exit(0);
+ exit(EXIT_SUCCESS);
case '?':
case 'h':
default:
usage();
- exit(1);
+ exit(EXIT_FAILURE);
}
}
@@ -416,7 +416,8 @@ int main(int argc, char **argv)
/* Open UDP port */
if (udpchannel > 0) {
int status = open_udp(udphostport);
- if (status !=0) exit (1);
+ if (status !=0)
+ exit(EXIT_FAILURE);
}
/* Daemonize if the user requested it. */
@@ -484,7 +485,7 @@ int main(int argc, char **argv)
/* completed count */
(void)fprintf(stderr,
"gpsd2udp: normal exit after %ld packets\n",count);
- exit (0);
+ exit(EXIT_SUCCESS);
}
} // end count
} // end len > 3
@@ -493,7 +494,7 @@ int main(int argc, char **argv)
// This is an infinite loop, should never be here
/*@-unreachable@*/
fprintf (stderr, "gpsd2udp ERROR abnormal exit\n");
- exit (-1);
+ exit(EXIT_FAILURE);
}
/*@=compdef =usedef@*/