From: Stephen Hemminger <stephen@networkplumber.org>
To: Anton Moryakov <ant.v.moryakov@gmail.com>
Cc: netdev@vger.kernel.org
Subject: Re: [PATCH] ip: handle NULL return from localtime in strxf_time in
Date: Sat, 15 Feb 2025 20:41:43 -0800 [thread overview]
Message-ID: <20250215204143.0ae30525@hermes.local> (raw)
In-Reply-To: <20250216022523.647342-1-ant.v.moryakov@gmail.com>
On Sun, 16 Feb 2025 05:25:23 +0300
Anton Moryakov <ant.v.moryakov@gmail.com> wrote:
> Static analyzer reported:
> Pointer 'tp', returned from function 'localtime' at ipxfrm.c:352, may be NULL
> and is dereferenced at ipxfrm.c:354 by calling function 'strftime'.
>
> Corrections explained:
> The function localtime() may return NULL if the provided time value is
> invalid. This commit adds a check for NULL and handles the error case
> by copying "invalid-time" into the output buffer.
> Unlikely, but may return an error
>
> Triggers found by static analyzer Svace.
>
> Signed-off-by: Anton Moryakov <ant.v.moryakov@gmail.com>
Seems like you are creating dead code. Unless glibc is broken
this can never happen.
prev parent reply other threads:[~2025-02-16 4:41 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-16 2:25 [PATCH] ip: handle NULL return from localtime in strxf_time in Anton Moryakov
2025-02-16 4:41 ` Stephen Hemminger [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250215204143.0ae30525@hermes.local \
--to=stephen@networkplumber.org \
--cc=ant.v.moryakov@gmail.com \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox