NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

lib/59067: wctrans got error member.



>Number:         59067
>Category:       lib
>Synopsis:       wctrans got error member.
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    lib-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Tue Feb 11 02:40:00 +0000 2025
>Originator:     rujin
>Release:        trunk
>Organization:
ACOINFO
>Environment:
NetBSD 10.1 NetBSD 10.1(GENERIC) #0: Mon Dec 16 13.08:11 UTC 2024 mkrepro%mkrepro.NetBSD.org@localhost:/usr/src/sys/arch/amd64/compile/GENERIC amd64
>Description:
wctrans got error member make a crash on running.
>How-To-Repeat:
use this code:

#include <stdio.h>
#include <wchar.h>
#include <locale.h>
#include <wctype.h>
#include <wchar.h>

int main()
{
    printf("set locale: %s\n", setlocale(LC_ALL, ""));

    wchar_t wc = L'A'; 
    wctrans_t lower = wctrans("towlower"); 

    // crash on this line
    wchar_t res = towctrans(wc, lower);

    if (res != WEOF) {
        printf("wc: %lc, res: %lc\n", wc, res);
    } else {
        printf("test failed!\n");
    }

    return 0;
}
>Fix:
https://github.com/NetBSD/src/blob/trunk/lib/libc/locale/iswctype_mb.c 

line 132 update to:

return (wctrans_t)__UNCONST(&rl->rl_wctype[i]);  

  =====>  

return (wctrans_t)__UNCONST(&rl->rl_wctrans[i]);



Home | Main Index | Thread Index | Old Index