Bugzilla – Attachment 183633 Details for
Bug 40270
Remove useless warnings on failed SIP2 login
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40270: Fix uninitialized value warnings in SIP logging
Bug-40270-Fix-uninitialized-value-warnings-in-SIP-.patch (text/plain), 2.72 KB, created by
David Nind
on 2025-06-27 20:38:04 UTC
(
hide
)
Description:
Bug 40270: Fix uninitialized value warnings in SIP logging
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-06-27 20:38:04 UTC
Size:
2.72 KB
patch
obsolete
>From 4f6ebcbae509229141edc526fccf5625237c75a6 Mon Sep 17 00:00:00 2001 >From: Tomas Cohen Arazi <tomascohen@theke.io> >Date: Fri, 27 Jun 2025 16:42:30 -0300 >Subject: [PATCH] Bug 40270: Fix uninitialized value warnings in SIP logging > >The SIP server generates warnings when logging account information >for failed logins: > >Use of uninitialized value $args[0] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314 >Use of uninitialized value $args[1] in sprintf at /kohadevbox/koha/C4/SIP/Sip.pm line 314 > >This occurs when $self->{account}->{id} or $self->{account}->{institution} >are undefined during failed authentication attempts. > >This patch fixes the issue by: >1. Adding a safer sprintf implementation in siplog that handles undefined values >2. Providing default values for undefined account information in logging calls > >To test: >1. Start SIP server >2. Attempt to connect with invalid credentials using sip_cli_emulator.pl: > ./misc/sip_cli_emulator.pl -a 127.0.0.1 -p 6001 -su invaliduser -sp wrongpass -l kohalibrary2 --patron koha -m patron_information >3. Check /var/log/koha/kohadev/sip-output.log >=> FAIL: 'Use of uninitialized value...' warns >4. Apply this patch >5. Repeat 2 >=> SUCCESS: No "Use of uninitialized value" warnings appear >=> SUCCESS: Logging shows 'undef/undef' for failed logins instead of empty strings >6. Try a valid login >=> SUCCESS: Still works correctly for valid logins >7. Sign off :-D > >Signed-off-by: David Nind <david@davidnind.com> >--- > C4/SIP/SIPServer.pm | 4 ++-- > C4/SIP/Sip.pm | 10 +++++++++- > 2 files changed, 11 insertions(+), 3 deletions(-) > >diff --git a/C4/SIP/SIPServer.pm b/C4/SIP/SIPServer.pm >index d897a55a37..186373b3c8 100644 >--- a/C4/SIP/SIPServer.pm >+++ b/C4/SIP/SIPServer.pm >@@ -323,8 +323,8 @@ sub raw_transport { > > siplog( > "LOG_DEBUG", "raw_transport: uname/inst: '%s/%s'", >- $self->{account}->{id}, >- $self->{account}->{institution} >+ $self->{account}->{id} // 'undef', >+ $self->{account}->{institution} // 'undef' > ); > if ( !$self->{account}->{id} ) { > siplog( "LOG_ERR", "Login failed shutting down" ); >diff --git a/C4/SIP/Sip.pm b/C4/SIP/Sip.pm >index c1450c8dff..c4cff7ee94 100644 >--- a/C4/SIP/Sip.pm >+++ b/C4/SIP/Sip.pm >@@ -311,7 +311,15 @@ sub siplog { > : $level eq 'LOG_WARNING' ? 'warn' > : 'error'; > >- my $message = @args ? sprintf( $mask, @args ) : $mask; >+ my $message; >+ if (@args) { >+ >+ # Replace undefined values with 'undef' to prevent sprintf warnings >+ my @safe_args = map { defined($_) ? $_ : 'undef' } @args; >+ $message = sprintf( $mask, @safe_args ); >+ } else { >+ $message = $mask; >+ } > > $message = remove_password_from_message($message); > >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40270
:
183631
| 183633