Page MenuHome GnuPG

Potential use of uniinitialized vairaible
Closed, ResolvedPublic

Description

export CC=/usr/local/bin/clang
export CXX=/usr/local/bin/clang++
export CPPFLAGS="-fsanitize=address -fsanitize=undefined"
export CFLAGS="-fsanitize=address -fsanitize=undefined"
export CFLAGS="-fsanitize=address -fsanitize=undefined -fno-sanitize=vptr"

export PREFIX=~/gpg-sanitize

LIBRARY=libksba
VERSION=1.3.2
FILE="$LIBRARY-$VERSION"

cd "$FILE"
./configure --enable-static --disable-shared
--with-libgpg-error-prefix="$PREFIX" --prefix="$PREFIX"
make

make check | /usr/local/bin/asan_symbolize.py


...
libtool: compile: /usr/local/bin/clang -DHAVE_CONFIG_H -I. -I.. -I../gl -I../gl
-fsanitize=address -fsanitize=undefined -I/home/jwalton/gpg-sanitize/include
-fsanitize=address -fsanitize=undefined -fno-sanitize=vptr -Wall -Wcast-align
-Wshadow -Wstrict-prototypes -Wpointer-arith -Wno-pointer-sign
-fvisibility=hidden -MT cert.lo -MD -MP -MF .deps/cert.Tpo -c cert.c -o cert.o
cert.c:466:7: warning: variable 'algo' is used uninitialized whenever 'if'

    condition is true [-Wsometimes-uninitialized]
if (!n || n->off == -1)
    ^~~~~~~~~~~~~~~~~~

cert.c:476:10: note: uninitialized use occurs here

return algo;
       ^~~~

cert.c:466:3: note: remove the 'if' if its condition is always false

if (!n || n->off == -1)
^~~~~~~~~~~~~~~~~~~~~~~

cert.c:466:7: warning: variable 'algo' is used uninitialized whenever '||'

    condition is true [-Wsometimes-uninitialized]
if (!n || n->off == -1)
    ^~

cert.c:476:10: note: uninitialized use occurs here

return algo;
       ^~~~

cert.c:466:7: note: remove the '||' if its condition is always false

if (!n || n->off == -1)
    ^~~~~

cert.c:442:13: note: initialize the variable 'algo' to silence this warning

char *algo;
          ^
           = NULL

2 warnings generated.

Details

Version
1.3.2

Event Timeline

JW added projects: libksba, Bug Report.
JW added a subscriber: JW.

Updated cert.c which initializes the variable algo.

Changed status to 'unread'. I'm not chatting.

werner claimed this task.
werner added a project: Mistaken.

No c+p of warnings please! Use gnupg-devel for such things.

(If you want to provide a fix, please provide a diff and not the complete file.)