Closed Bug 864248 Opened 11 years ago Closed 11 years ago

Netd BandwidthController segmentation fault

Categories

(Firefox OS Graveyard :: General, defect)

ARM
Gonk (Firefox OS)
defect
Not set
normal

Tracking

(Not tracked)

RESOLVED FIXED

People

(Reporter: albert, Assigned: albert)

References

Details

Attachments

(1 file, 2 obsolete files)

In function  BandwidthController::setCostlyAlert of netd/BandwidthController.cpp file, line 885:

 asprintf(&alertQuotaCmd, ALERT_IPT_TEMPLATE, "-I", chainNameAndPos, bytes, alertName, alertName);

Having that: const char BandwidthController::ALERT_IPT_TEMPLATE[] = "%s %s
%s -m quota2 ! --quota %lld --name %s";
the asprintf throws a segmentation fault because bytes is long instead of
string.
Blocks: 858005
Attachment #740229 - Flags: review?(mvines)
Comment on attachment 740229 [details] [diff] [review]
Fix segmentation fault according to the needed rule of iptable

Review of attachment 740229 [details] [diff] [review]:
-----------------------------------------------------------------

::: BandwidthController.cpp
@@ +48,4 @@
>  #include "oem_iptables_hook.h"
>  
>  /* Alphabetical */
> +const char BandwidthController::ALERT_IPT_TEMPLATE[] = "%s %s -m quota2 ! --quota %lld --name %s";

I see ALERT_IPT_TEMPLATE used in other asprintf()s in this file, so I think that removing the 3rd %s will break them.   Would an alternate solution be to add an empty string, "", to the argument list on line 886 between the |chainNameAndPos| and |bytes| arguments?
Attachment #740229 - Flags: review?(mvines)
(In reply to Michael Vines [:m1] [:evilmachines] from comment #2)
> Comment on attachment 740229 [details] [diff] [review]
> Fix segmentation fault according to the needed rule of iptable
> 
> Review of attachment 740229 [details] [diff] [review]:
> -----------------------------------------------------------------
> 
> ::: BandwidthController.cpp
> @@ +48,4 @@
> >  #include "oem_iptables_hook.h"
> >  
> >  /* Alphabetical */
> > +const char BandwidthController::ALERT_IPT_TEMPLATE[] = "%s %s -m quota2 ! --quota %lld --name %s";
> 
> I see ALERT_IPT_TEMPLATE used in other asprintf()s in this file, so I think
> that removing the 3rd %s will break them.   Would an alternate solution be
> to add an empty string, "", to the argument list on line 886 between the
> |chainNameAndPos| and |bytes| arguments?

Add an empty string "" does not solve the problem because it causes a double space and later the string is parsed by blank spaces to split command and arguments. As a result, command exec fails.

To solve it I placed an empty string to the first parameter and then remove the first space.
Attachment #740229 - Attachment is obsolete: true
Attachment #742226 - Flags: review?(mvines)
Assignee: nobody → acperez
memmove index was wrong in previous patch
Attachment #742226 - Attachment is obsolete: true
Attachment #742226 - Flags: review?(mvines)
Attachment #742996 - Flags: review?(mvines)
Attachment #742996 - Flags: review?(mvines) → review+
All bugs blocking bug 858005 are landed but this one, so we need this one to be landed in a branch, as it is required for Firefox OX 1.2. Or maybe you already have a new version of netd for Firefox OS 1.2?
Flags: needinfo?(mvines)
Thanks for the reminder.  I've landed this in our ICS tree and should appear on CAF early next week at https://www.codeaurora.org/cgit/quic/la/platform/system/netd/log/?h=b2g_ics_1.2 

It looks like JB MR2 netd is not affected.
Flags: needinfo?(mvines)
Stay tuned, it's landed honest :)
It has yet to be pushed to CAF due to unrelated issues, might be more toward the latter half of the week before it appears (at which point that branch will become valid).
Fixed for hamachi
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: