Skip to content
Snippets Groups Projects
utils.c 52.2 KiB
Newer Older
  • Learn to ignore specific revisions
  • 		} else if (!strcasecmp(key, "qop") && !strcasecmp(val, "auth")) {
    			d->qop = 1;
    		} else if (!strcasecmp(key, "nc")) {
    			unsigned long u;
    			if (sscanf(val, "%lx", &u) != 1) {
    				ast_log(LOG_WARNING, "Incorrect Digest nc value: \"%s\".\n", val);
    				return -1;
    			}
    			ast_string_field_set(d, nc, val);
    		}
    	}
    	ast_free(str);
    
    	/* Digest checkout */
    	if (ast_strlen_zero(d->realm) || ast_strlen_zero(d->nonce)) {
    		/* "realm" and "nonce" MUST be always exist */
    		return -1;
    	}
    
    	if (!request) {
    		/* Additional check for Digest response */
    		if (ast_strlen_zero(d->username) || ast_strlen_zero(d->uri) || ast_strlen_zero(d->response)) {
    			return -1;
    		}
    
    		if (pedantic && d->qop && (ast_strlen_zero(d->cnonce) || ast_strlen_zero(d->nc))) {
    			return -1;
    		}
    	}
    
    	return 0;
    }
    
    
    #ifndef __AST_DEBUG_MALLOC
    int _ast_asprintf(char **ret, const char *file, int lineno, const char *func, const char *fmt, ...)
    {
    	int res;
    	va_list ap;
    
    	va_start(ap, fmt);
    	if ((res = vasprintf(ret, fmt, ap)) == -1) {
    		MALLOC_FAILURE_MSG;
    	}
    	va_end(ap);
    
    	return res;
    }
    #endif