*** check_snmp.c Thu Aug 4 14:33:54 2011 --- check_snmp_64bit_fix.c Thu Aug 4 14:17:49 2011 *************** *** 85,91 **** int process_arguments (int, char **); int validate_arguments (void); ! char *thisarg (char *str); char *nextarg (char *str); void print_usage (void); void print_help (void); --- 85,91 ---- int process_arguments (int, char **); int validate_arguments (void); ! char *trimstring (char *str); char *nextarg (char *str); void print_usage (void); void print_help (void); *************** *** 180,187 **** bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); ! labels = malloc (labels_size); ! unitv = malloc (unitv_size); for (i = 0; i < MAX_OIDS; i++) eval_method[i] = CHECK_UNDEF; --- 180,187 ---- bindtextdomain (PACKAGE, LOCALEDIR); textdomain (PACKAGE); ! labels = malloc (sizeof(char *) * labels_size); ! unitv = malloc (sizeof(char *) * unitv_size); for (i = 0; i < MAX_OIDS; i++) eval_method[i] = CHECK_UNDEF; *************** *** 737,760 **** nlabels++; if (nlabels >= labels_size) { labels_size += 8; ! labels = realloc (labels, labels_size); if (labels == NULL) die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), (int)nlabels); } ! labels[nlabels - 1] = optarg; ! ptr = thisarg (optarg); labels[nlabels - 1] = ptr; if (strstr (ptr, "'") == ptr) labels[nlabels - 1] = ptr + 1; while (ptr && (ptr = nextarg (ptr))) { if (nlabels >= labels_size) { labels_size += 8; ! labels = realloc (labels, labels_size); if (labels == NULL) die (STATE_UNKNOWN, _("Could not reallocate labels\n")); } labels++; ! ptr = thisarg (ptr); if (strstr (ptr, "'") == ptr) labels[nlabels - 1] = ptr + 1; else --- 738,760 ---- nlabels++; if (nlabels >= labels_size) { labels_size += 8; ! labels = realloc (labels, sizeof(char *) * labels_size); if (labels == NULL) die (STATE_UNKNOWN, _("Could not reallocate labels[%d]"), (int)nlabels); } ! ptr = trimstring (optarg); labels[nlabels - 1] = ptr; if (strstr (ptr, "'") == ptr) labels[nlabels - 1] = ptr + 1; while (ptr && (ptr = nextarg (ptr))) { if (nlabels >= labels_size) { labels_size += 8; ! labels = realloc (labels, sizeof(char *) * labels_size); if (labels == NULL) die (STATE_UNKNOWN, _("Could not reallocate labels\n")); } labels++; ! ptr = trimstring (ptr); if (strstr (ptr, "'") == ptr) labels[nlabels - 1] = ptr + 1; else *************** *** 766,789 **** nunits++; if (nunits >= unitv_size) { unitv_size += 8; ! unitv = realloc (unitv, unitv_size); if (unitv == NULL) die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), (int)nunits); } ! unitv[nunits - 1] = optarg; ! ptr = thisarg (optarg); unitv[nunits - 1] = ptr; if (strstr (ptr, "'") == ptr) unitv[nunits - 1] = ptr + 1; while (ptr && (ptr = nextarg (ptr))) { if (nunits >= unitv_size) { unitv_size += 8; ! unitv = realloc (unitv, unitv_size); if (units == NULL) die (STATE_UNKNOWN, _("Could not realloc() units\n")); } nunits++; ! ptr = thisarg (ptr); if (strstr (ptr, "'") == ptr) unitv[nunits - 1] = ptr + 1; else --- 766,788 ---- nunits++; if (nunits >= unitv_size) { unitv_size += 8; ! unitv = realloc (unitv, sizeof(char *) * unitv_size); if (unitv == NULL) die (STATE_UNKNOWN, _("Could not reallocate units [%d]\n"), (int)nunits); } ! ptr = trimstring (optarg); unitv[nunits - 1] = ptr; if (strstr (ptr, "'") == ptr) unitv[nunits - 1] = ptr + 1; while (ptr && (ptr = nextarg (ptr))) { if (nunits >= unitv_size) { unitv_size += 8; ! unitv = realloc (unitv, sizeof(char *) * unitv_size); if (units == NULL) die (STATE_UNKNOWN, _("Could not realloc() units\n")); } nunits++; ! ptr = trimstring (ptr); if (strstr (ptr, "'") == ptr) unitv[nunits - 1] = ptr + 1; else *************** *** 936,942 **** if there is a leading quote, make sure it balances */ char * ! thisarg (char *str) { str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */ --- 935,941 ---- if there is a leading quote, make sure it balances */ char * ! trimstring (char *str) { str += strspn (str, " \t\r\n"); /* trim any leading whitespace */ if (strstr (str, "'") == str) { /* handle SIMPLE quoted strings */