[Serdev] [Tracker] Created: (SER-205) Wrong typecast in module
gflags
Anonymous (JIRA)
tracker at iptel.org
Wed Jan 10 14:02:26 UTC 2007
Wrong typecast in module gflags
-------------------------------
Key: SER-205
URL: http://tracker.iptel.org/browse/SER-205
Project: SER
Issue Type: Bug
Components: Unspecified
Affects Versions: Ottendorf
Environment: 0.10.99-dev64, module/gflags/gflags.c revision 1.19, sr_module.c revision 1.49
Priority: Minor
Functions set_gflag, reset_gflag, is_gflag treat given parameter flag_par as unisgned long int* while fixup_int_1 (i.e. fix_param, respectively) returns an fparam_t*. This results in a strange behavior as documented by Hendrik Scholz in message <459CFD83.9090704 at freenet-ag.de> ("off-by-one error").
Proposed patch:
===================================================================
RCS file: /cvsroot/ser/sip_router/modules/gflags/gflags.c,v
retrieving revision 1.19
diff -u -B -b -r1.19 gflags.c
--- gflags.c 12 Dec 2006 15:31:08 -0000 1.19
+++ gflags.c 10 Jan 2007 14:00:56 -0000
@@ -126,7 +126,12 @@
{
unsigned long int flag;
- flag=*((unsigned long int*)flag_par);
+ if ( !flag_par || ((fparam_t*)flag_par)->type != FPARAM_INT ) {
+ LOG(L_ERR, "gflags:set_gflag: Invalid parameter\n");
+ return -1;
+ }
+
+ flag=((fparam_t*)flag_par)->v.i;
(*gflags) |= 1 << flag;
return 1;
}
@@ -135,7 +140,12 @@
{
unsigned long int flag;
- flag=*((unsigned long int*)flag_par);
+ if ( !flag_par || ((fparam_t*)flag_par)->type != FPARAM_INT ) {
+ LOG(L_ERR, "gflags:reset_gflag: Invalid parameter\n");
+ return -1;
+ }
+
+ flag=((fparam_t*)flag_par)->v.i;
(*gflags) &= ~ (1 << flag);
return 1;
}
@@ -144,7 +154,12 @@
{
unsigned long int flag;
- flag=*((unsigned long int*)flag_par);
+ if ( !flag_par || ((fparam_t*)flag_par)->type != FPARAM_INT ) {
+ LOG(L_ERR, "gflags:is_gflag: Invalid parameter\n");
+ return -1;
+ }
+
+ flag=((fparam_t*)flag_par)->v.i;
return ( (*gflags) & (1<<flag)) ? 1 : -1;
}
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://tracker.iptel.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the Serdev
mailing list