"Fix" for third-party code



  • This isn't so much a WTF, more of a crazy stupid thing I had to do to fix something and I really had no other options.

    So what do you do if a third-party web service (hosted by a different third-party) your product consumes changes slightly and introduces a bug which forces a third-party library (from the same vendor even) to fail spectacularly, and this is happening on production web sites that need to be running? Mind you, all the problems are in third-party code so you can't properly fix it!

    The bug in question is the service metadata has some values that are supposed to be doubles but are slightly outside the allowable range for the double datatype, likely due to rounding issues. The library apparently uses Double.Parse on it and fails.

    The solution? Since this web request happens to go through a custom-written proxy that I wrote, modify the proxy to detect when a request is going to the service in question and tamper with the response to modify those values into something that Double.Parse can safely handle.

    The best part? None of us have any ideas what those values mean or how they affect the application. But the hack works.



  • That sounds like one picky Double.Parse. In what way were the values out-of-range? Too many sig figs or something else? It's not easy to go out of range in the big<->small directions.



  • @superjer said:

    That sounds like one picky Double.Parse. In what way were the values out-of-range? Too many sig figs or something else? It's not easy to go out of range in the big<->small directions.

    Yeah, and if your data set is full of 2.2250738585072012e-308's then you're pretty weird.



  • Double.MaxValue: 1.7976931348623157E+308

    The value I received from the web service: 1.79769313486232E+308.

    I'm sure it's just a rounding issue from converting it to a string for display.



  • @mott555 said:

    Double.MaxValue: 1.7976931348623157E+308

    The value I received from the web service: 1.79769313486232E+308.

    I'm sure it's just a rounding issue from converting it to a string for display.

    Dear friend,

    I know that this mail will be a big surprise to you, please consider it and accept it with deep sense of humility. I have a business which will be beneficial to both of us. the amount of money involved is [$ 1.79769313486232E+308] which i want to transfer out of the country to your bank account, all to my financial benefit and yours too. and also to take my wife abroad for treatment of liver damage. I want to transfer this money out of the country but such fund cannot be transferred to any except to your esteemed business, the only such business I could find that could handle such a large transaction, being as it may slightly larger than the Double's usual MaxValue of 1.7976931348623157E+308.

     

     



  • @mahlerrd said:

    Dear friend,

    I know that this mail will be a big surprise to you, please consider it and accept it with deep sense of humility. I have a business which will be beneficial to both of us. the amount of money involved is [$ 1.79769313486232E+308] which i want to transfer out of the country to your bank account, all to my financial benefit and yours too. and also to take my wife abroad for treatment of liver damage. I want to transfer this money out of the country but such fund cannot be transferred to any except to your esteemed business, the only such business I could find that could handle such a large transaction, being as it may slightly larger than the Double's usual MaxValue of 1.7976931348623157E+308.

     

     

    +1



  • @mott555 said:

    Double.MaxValue: 1.7976931348623157E+308

    The value I received from the web service: 1.79769313486232E+308.

    I'm sure it's just a rounding issue from converting it to a string for display.

    So there's almost certainly a line in there somewhere that says

    [code]if(unvalidated_input_data == Double.MaxValue) {...[/code]

    Thereby breaking three DONT's in one line, possibly four.



  • @mott555 said:

    This isn't so much a WTF, more of a crazy stupid thing I had to do to fix something and I really had no other options.

    So what do you do if a third-party web service (hosted by a different third-party) your product consumes changes slightly and introduces a bug which forces a third-party library (from the same vendor even) to fail spectacularly, and this is happening on production web sites that need to be running? Mind you, all the problems are in third-party code so you can't properly fix it!

    The bug in question is the service metadata has some values that are supposed to be doubles but are slightly outside the allowable range for the double datatype, likely due to rounding issues. The library apparently uses Double.Parse on it and fails.

    The solution? Since this web request happens to go through a custom-written proxy that I wrote, modify the proxy to detect when a request is going to the service in question and tamper with the response to modify those values into something that Double.Parse can safely handle.

    The best part? None of us have any ideas what those values mean or how they affect the application. But the hack works.

    It appears that readiness, willingness and ability to implement bugfixes to third party code as and when it is needed is now part of the job description of your typical programming job.


    My colleague is still down in the depths of Liferay as I type. As I am no longer in the zone programming-wise, I'm doing further resource investigation work, and have another sidebar entry on its way ...


Log in to reply