We need to check if the strchr() call returns NULL (due to missing
char) before we use the returned value in arithmetic. There is no
live bug here, but fixing it before it can become for hygiene.
Closes: #8814
Reviewed-by: Daniel Stenberg <daniel@haxx.se>
if(!service) {
tmp0 = hostname;
tmp1 = strchr(tmp0, '.');
- len = tmp1 - tmp0;
- if(!tmp1 || len < 1) {
+ if(!tmp1) {
infof(data, "service missing in parameters or hostname");
ret = CURLE_URL_MALFORMAT;
goto fail;
}
+ len = tmp1 - tmp0;
service = Curl_memdup(tmp0, len + 1);
if(!service) {
goto fail;
if(!region) {
tmp0 = tmp1 + 1;
tmp1 = strchr(tmp0, '.');
- len = tmp1 - tmp0;
- if(!tmp1 || len < 1) {
+ if(!tmp1) {
infof(data, "region missing in parameters or hostname");
ret = CURLE_URL_MALFORMAT;
goto fail;
}
+ len = tmp1 - tmp0;
region = Curl_memdup(tmp0, len + 1);
if(!region) {
goto fail;