Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unexpected behavior of curl_url_set for empty string (DEBUGASSERT) #11714

Closed
ad0p opened this issue Aug 23, 2023 · 3 comments
Closed

Unexpected behavior of curl_url_set for empty string (DEBUGASSERT) #11714

ad0p opened this issue Aug 23, 2023 · 3 comments

Comments

@ad0p
Copy link

ad0p commented Aug 23, 2023

I did this

I am trying to use curl_url_set with CURLU_DEFAULT_SCHEME option to validate a string and check whether it's a valid URL.

Now, our tests fail when calling curl_url_set on empty string with DEBUGBUILD.

It fails on urlapi.c:1245

DEBUGASSERT(pathlen < urllen);

With release build, it returns CURLUE_OK

Is it expected for empty string URL to fail here and just for DEBUGBUILD?

I expected the following

Release build says that empty string is a valid URL, debug build fails on assertion. I would expect the same behavior in both.

curl/libcurl version

curl 8.2.1

operating system

not relevant

@bagder
Copy link
Member

bagder commented Aug 23, 2023

Setting a blank URL does not assert for me.

It should return an error.

#include <curl/curl.h>

int main(void)
{
  curl_global_init(CURL_GLOBAL_ALL);
  CURLU *u = curl_url();
  curl_url_set(u, CURLUPART_URL, "", 0);
  curl_global_cleanup();
}

@ad0p
Copy link
Author

ad0p commented Aug 23, 2023

I apologize, I forgot to mention that we use curl_url_set with CURLU_DEFAULT_SCHEME option... you are right, without this flag, behavior is different.

bagder added a commit that referenced this issue Aug 23, 2023
Test it in 1560
Fixes #11714
Reported-by: ad0p on github
@bagder
Copy link
Member

bagder commented Aug 23, 2023

#11715 now makes this return CURLUE_MALFORMED_INPUT

@bagder bagder closed this as completed in 887b998 Aug 23, 2023
ptitSeb pushed a commit to wasix-org/curl that referenced this issue Sep 25, 2023
Test it in 1560
Fixes curl#11714
Reported-by: ad0p on github
Closes curl#11715
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants