From f4dbb204f1ad99179c145558ababf1190f067083 Mon Sep 17 00:00:00 2001 From: Dan McGee Date: Wed, 15 Aug 2007 20:16:46 -0400 Subject: src/util: Clean up headers and a few fixes Remove some unnecessary headers in the two utilities as well as fix a possible non-null termination issue in vercmp. Signed-off-by: Dan McGee --- src/util/vercmp.c | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/util/vercmp.c') diff --git a/src/util/vercmp.c b/src/util/vercmp.c index cc951988..873ef1c9 100644 --- a/src/util/vercmp.c +++ b/src/util/vercmp.c @@ -21,29 +21,26 @@ #include "config.h" -#include -#include -#include -#include -#include -/* TODO this is probably not the best way to do this */ -#ifndef PATH_MAX -#define PATH_MAX 1024 -#endif +#include /* printf */ +#include /* strncpy */ #include +#define MAX_LEN 255 + int main(int argc, char *argv[]) { - char s1[255] = ""; - char s2[255] = ""; + char s1[MAX_LEN] = ""; + char s2[MAX_LEN] = ""; int ret; if(argc > 1) { - strncpy(s1, argv[1], 255); + strncpy(s1, argv[1], MAX_LEN); + s1[MAX_LEN -1] = '\0'; } if(argc > 2) { - strncpy(s2, argv[2], 255); + strncpy(s2, argv[2], MAX_LEN); + s2[MAX_LEN -1] = '\0'; } else { printf("0\n"); return(0); -- cgit v1.2.3-24-g4f1b