Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
Do some error checking in register.c
Marin Atanasov Nikolov committed 14 years ago
commit 44642e34fa815ed343410d3c66deeafce49d6912
parent 7b46d0a
1 file changed +5 -3
modified pkg/register.c
@@ -41,7 +41,7 @@ static const char * const scripts[] = {
void
usage_register(void)
{
-
	fprintf(stderr, "usage: pkg register [-l] -m <metadatadir> -f <plist_file>\n\n");
+
	fprintf(stderr, "usage: pkg register [-ld] [-a <arch>] [-i <input-path>] -m <metadatadir> -f <plist-file>\n\n");
	fprintf(stderr, "For more information see 'pkg help register'.\n");
}

@@ -87,10 +87,12 @@ exec_register(int argc, char **argv)

				break;
			case 'm':
-
				mdir = strdup(optarg);
+
				if ((mdir = strdup(optarg)) == NULL)
+
					errx(1, "cannot allocate memory");
				break;
			case 'a':
-
				arch = strdup(optarg);
+
				if ((arch = strdup(optarg)) == NULL)
+
					errx(1, "cannot allocate memory");
				break;
			case 'd':
				pkg_setautomatic(pkg);