whosgonna created an issue (kamailio/kamailio#4332)

<!--
Kamailio Project uses GitHub Issues only for bugs in the code or feature 
requests. Please use this template only for bug reports.

If you have questions about using Kamailio or related to its configuration 
file, ask on sr-users mailing list:

  * 
https://lists.kamailio.org/mailman3/postorius/lists/sr-users.lists.kamailio.org/

If you have questions about developing extensions to Kamailio or its existing C 
code, ask on sr-dev mailing list:

  * 
https://lists.kamailio.org/mailman3/postorius/lists/sr-dev.lists.kamailio.org/

Please try to fill this template as much as possible for any issue. It helps 
the developers to troubleshoot the issue.

Note that an issue report may be closed automatically after about 2 months
if there is no interest from developers or community users on pursuing it, being
considered expired. In such case, it can be reopened by writing a comment that 
includes
the token `/notexpired`. About two weeks before considered expired, the issue is
marked with the label `stale`, trying to notify the submitter and everyone else
that might be interested in it. To remove the label `stale`, write a comment 
that
includes the token `/notstale`. Also, any comment postpone the `expire` 
timeline,
being considered that there is interest in pursuing the issue.

If there is no content to be filled in a section, the entire section can be 
removed.

You can delete the comments from the template sections when filling.

You can delete next line and everything above before submitting (it is a 
comment).
-->

### Description

We received a INVITE with non-ascii characters in the authentication username.  
The character set and  collation of the subscriber table is `latin1` and 
`latin1_swedish_ci`.  This generated the following failure (DB connection names 
are `primary` and `secondary`):

```
3(9) ERROR: db_mysql [km_dbase.c:127]: db_mysql_submit_query(): driver error on 
query: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and 
(utf8mb4_general_ci,COERCIBLE) for operation '=' (1267)
3(9) ERROR: <core> [lib/srdb1/db_query.c:158]: db_do_query_internal(): error 
while submitting query
3(9) WARNING: db_cluster [dbcl_api.c:513]: db_cluster_query(): serial operation 
- failure on cluster [db] (9/0) [primary]
3(9) ERROR: db_mysql [km_dbase.c:127]: db_mysql_submit_query(): driver error on 
query: Illegal mix of collations (latin1_swedish_ci,IMPLICIT) and 
(utf8mb4_general_ci,COERCIBLE) for operation '=' (1267)
3(9) ERROR: <core> [lib/srdb1/db_query.c:158]: db_do_query_internal(): error 
while submitting query
3(9) WARNING: db_cluster [dbcl_api.c:513]: db_cluster_query(): serial operation 
- failure on cluster [db] (8/0) [secondary]
3(9) ERROR: db_cluster [dbcl_api.c:513]: db_cluster_query(): no successful read 
on cluster [db]
3(9) ERROR: auth_db [authorize.c:180]: get_ha1(): failed to query database
3(9) ERROR: [DIGEST_AUTH 60e4abd540674d4aa8961d380411585e@0.0.0.0 
INVITE-124524] Generic failure in authentication. Send '503 Server Error' and 
exit.
```

While using the limited character set in the database (and it's associated 
collation) is questionable, and I don't expect the query to succeed, the issue 
is that this single query failure is causing the connections to be disabled in 
the db_cluster.

### Troubleshooting

#### Reproduction

I haven't tried to reproduce this, but I would assume it's easy to do.  I can 
probably mock it up in docker fairly quickly.  As a safety measure, I'll be 
validating the field with `is_alphanum()`


#### Log Messages

(as in description)



#### SIP Traffic

The `Username` in the `Proxy-Authorization` header as "\uFEFF1011".  As hex 
it's:
```
22 ef bb bf 31 30 31 31 22
```

### Possible Solutions

<!--
If you found a solution or workaround for the issue, describe it. Ideally, 
provide a pull request with a fix.
-->

### Additional Information

  * **Kamailio Version** - output of `kamailio -v`

```
version: kamailio 6.0.1 (aarch64/linux)
flags: USE_TCP, USE_TLS, USE_SCTP, TLS_HOOKS, USE_RAW_SOCKS, DISABLE_NAGLE, 
USE_MCAST, DNS_IP_HACK, SHM_MMAP, PKG_MALLOC, MEM_JOIN_FREE, Q_MALLOC, 
F_MALLOC, TLSF_MALLOC, DBG_SR_MEMORY, USE_FUTEX, FAST_LOCK-ADAPTIVE_WAIT-NOSMP, 
USE_DNS_CACHE, USE_DNS_FAILOVER, USE_NAPTR, USE_DST_BLOCKLIST, HAVE_RESOLV_RES, 
TLS_PTHREAD_MUTEX_SHARED
ADAPTIVE_WAIT_LOOPS 1024, MAX_RECV_BUFFER_SIZE 262144, MAX_SEND_BUFFER_SIZE 
262144, MAX_URI_SIZE 1024, BUF_SIZE 65535, DEFAULT PKG_SIZE 8MB
poll method support: poll, epoll_lt, epoll_et, sigio_rt, select.
id: unknown
compiled on 18:45:18 Mar 14 2025 with gcc 14.2.0

```

* **Operating System**:

<!--
Details about the operating system, the type: Linux (e.g.,: Debian 8.4, Ubuntu 
16.04, CentOS 7.1, ...), MacOS, xBSD, Solaris, ...;
Kernel details (output of `lsb_release -a` and `uname -a`)
-->

Container:
```
NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.21.2
PRETTY_NAME="Alpine Linux v3.21"
HOME_URL="https://alpinelinux.org/";
BUG_REPORT_URL="https://gitlab.alpinelinux.org/alpine/aports/-/issues";
```

Host:
```
NAME="Amazon Linux"
VERSION="2023"
ID="amzn"
ID_LIKE="fedora"
VERSION_ID="2023"
PLATFORM_ID="platform:al2023"
PRETTY_NAME="Amazon Linux 2023"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2023"
HOME_URL="https://aws.amazon.com/linux/";
BUG_REPORT_URL="https://github.com/amazonlinux/amazon-linux-2023";
```

Kernel (`uname -a)`:
```
Linux use2apocor01.n.fl.gg 6.1.56-82.125.amzn2023.aarch64 #1 SMP Tue Oct 10 
17:03:29 UTC 2023 aarch64 aarch64 aarch64 GNU/Linux
```

-- 
Reply to this email directly or view it on GitHub:
https://github.com/kamailio/kamailio/issues/4332
You are receiving this because you are subscribed to this thread.

Message ID: <kamailio/kamailio/issues/4...@github.com>
_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to