len = strlen( kIODeviceTreePlane ":" );
maxLen -= len;
- if( maxLen < 0)
+ if( maxLen <= 0)
continue;
- strcpy( buf, kIODeviceTreePlane ":" );
+ strlcpy( buf, kIODeviceTreePlane ":", len + 1 );
comp = buf + len;
// remove parameters following ':' from the path
len = skip - path;
maxLen -= len;
- if( maxLen < 0)
+ if( maxLen <= 0)
continue;
- strncpy( comp, path, len );
- comp[ len ] = 0;
+ strlcpy( comp, path, len + 1 );
matching = IOService::serviceMatching( "IONetworkInterface" );
if( !matching)
long partition = -1;
long lun = -1;
char c;
+ int len;
// scan the tail of the path for "@unit:partition"
do {
if( c || unit == -1 || partition == -1)
continue;
- maxLen -= strlen( "{" kIOPathMatchKey "='" kIODeviceTreePlane ":" );
- maxLen -= ( alias ? strlen( alias ) : 0 ) + (look - path);
- maxLen -= strlen( "/@hhhhhhhh,hhhhhhhh:dddddddddd';}" );
+ len = strlen( "{" kIOPathMatchKey "='" kIODeviceTreePlane ":" );
+ maxLen -= len;
+ if( maxLen <= 0)
+ continue;
- if( maxLen > 0) {
- sprintf( buf, "{" kIOPathMatchKey "='" kIODeviceTreePlane ":" );
- comp = buf + strlen( buf );
-
- if( alias) {
- strcpy( comp, alias );
- comp += strlen( alias );
- }
-
- if ( (look - path)) {
- strncpy( comp, path, look - path);
- comp += look - path;
- }
+ snprintf( buf, len + 1, "{" kIOPathMatchKey "='" kIODeviceTreePlane ":" );
+ comp = buf + len;
+
+ if( alias) {
+ len = strlen( alias );
+ maxLen -= len;
+ if( maxLen <= 0)
+ continue;
+
+ strlcpy( comp, alias, len + 1 );
+ comp += len;
+ }
+
+ if ( (look - path)) {
+ len = (look - path);
+ maxLen -= len;
+ if( maxLen <= 0)
+ continue;
+
+ strlcpy( comp, path, len + 1 );
+ comp += len;
+ }
- if ( lun != -1 )
- {
- sprintf ( comp, "/@%lx,%lx:%ld';}", unit, lun, partition );
- }
- else
- {
- sprintf( comp, "/@%lx:%ld';}", unit, partition );
- }
- } else
- continue;
+ if ( lun != -1 )
+ {
+ len = strlen( "/@hhhhhhhh,hhhhhhhh:dddddddddd';}" );
+ maxLen -= len;
+ if( maxLen <= 0)
+ continue;
+
+ snprintf( comp, len + 1, "/@%lx,%lx:%ld';}", unit, lun, partition );
+ }
+ else
+ {
+ len = strlen( "/@hhhhhhhh:dddddddddd';}" );
+ maxLen -= len;
+ if( maxLen <= 0)
+ continue;
+
+ snprintf( comp, len + 1, "/@%lx:%ld';}", unit, partition );
+ }
return( OSDynamicCast(OSDictionary, OSUnserialize( buf, 0 )) );
len = strlen( kIODeviceTreePlane ":" );
maxLen -= len;
- if( maxLen < 0)
+ if( maxLen <= 0)
continue;
- strcpy( buf, kIODeviceTreePlane ":" );
+ strlcpy( buf, kIODeviceTreePlane ":", len + 1 );
comp = buf + len;
len = strlen( path );
maxLen -= len;
- if( maxLen < 0)
+ if( maxLen <= 0)
continue;
- strncpy( comp, path, len );
- comp[ len ] = 0;
+ strlcpy( comp, path, len + 1 );
matching = OSDictionary::withCapacity( 1 );
if( !matching)
static int didRam = 0;
-kern_return_t IOFindBSDRoot( char * rootName,
+kern_return_t IOFindBSDRoot( char * rootName, unsigned int rootNameSize,
dev_t * root, u_int32_t * oflags )
{
mach_timespec_t t;
iostr = (OSString *) service->getProperty( kIOBSDNameKey );
if( iostr)
- strcpy( rootName, iostr->getCStringNoCopy() );
+ strlcpy( rootName, iostr->getCStringNoCopy(), rootNameSize );
off = (OSNumber *) service->getProperty( kIOBSDMajorKey );
if( off)
mjr = off->unsigned32BitValue();
} else {
IOLog( "Wait for root failed\n" );
- strcpy( rootName, "en0");
+ strlcpy( rootName, "en0", rootNameSize );
flags |= 1;
}