src/sbin/camcontrol/camcontrol.c
/*
 * Validates and copies the password in optarg to the passed buffer.
 * If the password in optarg is the same length as the buffer then
 * the data will still be copied but no null termination will occur.
 */
Validates and copies the password in optarg to the passed buffer.
If the password in optarg is the same length as the buffer then
the data will still be copied but no null termination will occur.
Validates and copies the password in optarg to the passed buffer . If the password in optarg is the same length as the buffer then the data will still be copied but no null termination will occur .
static int
ata_getpwd(u_int8_t *passwd, int max, char opt)
{
	int len;
	len = strlen(optarg);
	if (len > max) {
		warnx("-%c password is too long", opt);
		return (1);
	} else if (len == 0) {
		warnx("-%c password is missing", opt);
		return (1);
	} else if (optarg[0] == '-'){
		warnx("-%c password starts with '-' (generic arg?)", opt);
		return (1);
	} else if (strlen(passwd) != 0 && strcmp(passwd, optarg) != 0) {
		warnx("-%c password conflicts with existing password from -%c",
		      opt, pwd_opt);
		return (1);
	}
	strncpy(passwd, optarg, max);
	pwd_opt = opt;
	return (0);
}
static int ata_getpwd ( u_int8_t * passwd , int max , char opt ) { int len ; len = strlen ( optarg ) ; if ( len > max ) { warnx ( " " , opt ) ; return ( 1 ) ; } else if ( len == 0 ) { warnx ( " " , opt ) ; return ( 1 ) ; } else if ( optarg [ 0 ] == ' ' ) { warnx ( " " , opt ) ; return ( 1 ) ; } else if ( strlen ( passwd ) != 0 && strcmp ( passwd , optarg ) != 0 ) { warnx ( " " , opt , pwd_opt ) ; return ( 1 ) ; } strncpy ( passwd , optarg , max ) ; pwd_opt = opt ; return ( 0 ) ; }
Validates and copies the password in optarg to the passed buffer.
Validates and copies the password in optarg to the passed buffer .
/* Callers pass in a buffer which does NOT need to be terminated */