[Home]

Summary:ASTERISK-28825: Any curl response checks out as valid even if 404 is returned.
Reporter:dovid (dovid)Labels:patch
Date Opened:2020-04-13 12:56:47Date Closed:2020-11-06 11:49:04.000-0600
Priority:MinorRegression?
Status:Closed/CompleteComponents:Functions/func_curl
Versions:16.6.1 Frequency of
Occurrence
Related
Issues:
is a clone ofASTERISK-29070 CLONE - Any curl response checks out as valid even if 404 is returned.
is a clone ofASTERISK-29075 CLONE - Any curl response checks out as valid even if 404 is returned.
Environment:CentOS7, Asterisk 16.6.1Attachments:( 0) 28825-1.patch
( 1) 28825-2.patch
( 2) 28825-3.patch
Description:Hi,

In acf_curl_helper if there is any response then ret gets set to 0. This is the case regardless if the http response code that is sent back is a 200, 404 etc. It seems to be under if (args->cb_data.str && ast_str_strlen(args->cb_data.str)) {

For instance if the response is:
'<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /moh.php/single was not found on this server.</p>
</body></html>'

then Asterisk thinks the response was valid. If I do a curl request direct from the Linux CLI it looks like this

[root@a2-c2-nyc2 asterisk-16.6.1]# curl -I  http://localhost/moh.php
HTTP/1.1 404 Not Found
Date: Mon, 13 Apr 2020 17:55:50 GMT
Server: Apache/2.4.6 (CentOS) PHP/7.0.30
Content-Type: text/html; charset=iso-8859-1

[root@a2-c2-nyc2 asterisk-16.6.1]#
Comments:By: Asterisk Team (asteriskteam) 2020-04-13 12:56:49.611-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.

By: dovid (dovid) 2020-09-02 12:57:41.857-0500

Cleaned up the code a bit as per kharwell on IRC

<kharwell>One thing I'd do is instead of searching for a string I'd check the response code from curl itself: https://curl.haxx.se/libcurl/c/CURLINFO_RESPONSE_CODE.html
<kharwell>Also formatting wise (for Asterisk submissions/patches) the opening braces should be on the same line as the iif/else clause

By: Friendly Automation (friendly-automation) 2020-11-06 11:49:05.529-0600

Change 15066 merged by Friendly Automation:
func_curl.c: Allow user to set what return codes constitute a failure.

[https://gerrit.asterisk.org/c/asterisk/+/15066|https://gerrit.asterisk.org/c/asterisk/+/15066]

By: Friendly Automation (friendly-automation) 2020-11-06 12:40:48.274-0600

Change 15146 merged by Kevin Harwell:
func_curl.c: Allow user to set what return codes constitute a failure.

[https://gerrit.asterisk.org/c/asterisk/+/15146|https://gerrit.asterisk.org/c/asterisk/+/15146]

By: Friendly Automation (friendly-automation) 2020-11-06 12:41:11.352-0600

Change 15114 merged by Kevin Harwell:
func_curl.c: Allow user to set what return codes constitute a failure.

[https://gerrit.asterisk.org/c/asterisk/+/15114|https://gerrit.asterisk.org/c/asterisk/+/15114]