1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-12 09:18:10 +03:00

r15260: Don't dereference NULL pointers to obtain array lengths - found by

the IBM checker
This commit is contained in:
Jelmer Vernooij 2006-04-26 00:08:39 +00:00 committed by Gerald (Jerry) Carter
parent 72ae0dbaab
commit a492cd4bd4

View File

@ -116,6 +116,18 @@ sub get_value_of($)
} }
} }
#####################################################################
# check that a variable we get from ParseExpr isn't a null pointer
sub check_null_pointer($)
{
my $size = shift;
if ($size =~ /^\*/) {
my $size2 = substr($size, 1);
pidl "if ($size2 == NULL) return NT_STATUS_INVALID_PARAMETER_MIX;";
}
}
##################################################################### #####################################################################
# work out is a parse function should be declared static or not # work out is a parse function should be declared static or not
sub fn_declare($$) sub fn_declare($$)
@ -196,6 +208,7 @@ sub EjsPullArray($$$$$)
if (!$l->{IS_FIXED}) { if (!$l->{IS_FIXED}) {
pidl "EJS_ALLOC_N(ejs, $var, $size);"; pidl "EJS_ALLOC_N(ejs, $var, $size);";
} }
check_null_pointer($length);
pidl "ejs_pull_array_uint8(ejs, v, $name, $var, $length);"; pidl "ejs_pull_array_uint8(ejs, v, $name, $var, $length);";
return; return;
} }
@ -492,6 +505,7 @@ sub EjsPushArray($$$$$)
} }
# uint8 arrays are treated as data blobs # uint8 arrays are treated as data blobs
if ($nl->{TYPE} eq 'DATA' && $e->{TYPE} eq 'uint8') { if ($nl->{TYPE} eq 'DATA' && $e->{TYPE} eq 'uint8') {
check_null_pointer($length);
pidl "ejs_push_array_uint8(ejs, v, $name, $var, $length);"; pidl "ejs_push_array_uint8(ejs, v, $name, $var, $length);";
return; return;
} }