I am trying to create a text editor program that can be used to encrypt
and decrypt files. In order to ensure that there are no security holes
in the code I link in I am compiling crypto++ with the gcc options of
'-g -Wall -Werror'. 

In doing so I am noticing a few things missed with the old compiler
options of just '-g'. Is there a preferred format for sending in patches
to fix these warnings?

Here are the errors I get with crypto++ (v. CVS) and gcc (v. 3.2.3):

g++ -g -Wall -Werror -pipe -c 3way.cpp
cc1plus: warnings being treated as errors
In file included from seckey.h:10,
                 from 3way.h:7,
                 from 3way.cpp:5:
simple.h: In member function `unsigned int
   CryptoPP::InputRejecting<T>::Put2(const byte*, unsigned int, int,
bool)':
simple.h:94: warning: no return statement in function returning non-void
simple.h: In member function `bool
   CryptoPP::InputRejecting<T>::IsolatedMessageSeriesEnd(bool)':
simple.h:96: warning: no return statement in function returning non-void
simple.h: In member function `unsigned int
   CryptoPP::InputRejecting<T>::ChannelPut2(const std::string&, const
byte*,
   unsigned int, int, bool)':
simple.h:99: warning: no return statement in function returning non-void
simple.h: In member function `bool
   CryptoPP::InputRejecting<T>::ChannelMessageSeriesEnd(const
std::string&,
   int, bool)':
simple.h:100: warning: no return statement in function returning
non-void
misc.h: In member function `CryptoPP::GetBlock<T, B, A>&
CryptoPP::GetBlock<T,
   B, A>::operator()(U&) [with U = word32, T = word32, B =
CryptoPP::BigEndian,
   bool A = true]':
3way.cpp:89:   instantiated from here
misc.h:707: warning: unused variable `CryptoPP::CompileAssert<true>
   cryptopp_assert_707'
misc.h: In member function `CryptoPP::GetBlock<T, B, A>&
CryptoPP::GetBlock<T,
   B, A>::operator()(U&) [with U = word32, T = word32, B =
   CryptoPP::LittleEndian, bool A = true]':
3way.cpp:116:   instantiated from here
misc.h:707: warning: unused variable `CryptoPP::CompileAssert<true>
   cryptopp_assert_707'
make: *** [3way.o] Error 1

[PATCH]
? 3way.diff
cvs server: Diffing .
Index: GNUmakefile
===================================================================
RCS file: /cvsroot/cryptopp/c5/GNUmakefile,v
retrieving revision 1.12
diff -U2 -r1.12 GNUmakefile
--- GNUmakefile 22 Oct 2003 21:08:07 -0000      1.12
+++ GNUmakefile 3 Nov 2003 05:13:38 -0000
@@ -1,10 +1,10 @@
 # can't use -fno-rtti yet because it causes problems with exception
handling in GCC 2.95.2
-CXXFLAGS = -g
+CXXFLAGS = -g -Wall -Werror
 # Uncomment the next two lines to do a release build.
 # Note that you must define NDEBUG for your own application if you
define it for Crypto++.
 # Also, make sure you run the validation tests and test your own
program thoroughly
 # after turning on -O2. The GCC optimizer may have bugs that cause it
to generate incorrect code.
-# CXXFLAGS = -O2 -DNDEBUG -ffunction-sections -fdata-sections
-# LDFLAGS = -Wl,--gc-sections
+#CXXFLAGS = -O2 -Wall -Werror -DNDEBUG -ffunction-sections
-fdata-sections
+#LDFLAGS = -Wl,--gc-sections
 ARFLAGS = -cr  # ar needs the dash on OpenBSD
 RANLIB = ranlib
Index: misc.h
===================================================================
RCS file: /cvsroot/cryptopp/c5/misc.h,v
retrieving revision 1.9
diff -U2 -r1.9 misc.h
--- misc.h      4 Aug 2003 19:00:41 -0000       1.9
+++ misc.h      3 Nov 2003 05:13:38 -0000
@@ -705,8 +705,14 @@
        inline GetBlock<T, B, A> & operator()(U &x)
        {
-               CRYPTOPP_COMPILE_ASSERT(sizeof(U) >= sizeof(T));
-               x = GetWord<T>(A, B::ToEnum(), m_block);
-               m_block += sizeof(T);
-               return *this;
+         /* FIXME: Unused variable - 
+            CRYPTOPP_COMPILE_ASSERT(sizeof(U) >= sizeof(T));
+
+            SUGGESTION: Rather than using an assert we could
+            throw an exception. This way the program fails in
+            a more informative and graceful manner.
+         */
+         x = GetWord<T>(A, B::ToEnum(), m_block);
+         m_block += sizeof(T);
+         return *this;
        }
 
Index: seckey.h
===================================================================
RCS file: /cvsroot/cryptopp/c5/seckey.h,v
retrieving revision 1.5
diff -U2 -r1.5 seckey.h
--- seckey.h    25 Aug 2003 21:41:09 -0000      1.5
+++ seckey.h    3 Nov 2003 05:13:39 -0000
@@ -65,6 +65,21 @@
                obj->ThrowIfInvalidKeyLength(length);
                int rounds = param.GetIntValueWithDefault("Rounds",
obj->StaticGetDefaultRounds(length));
-               if (rounds < (unsigned int)MIN_ROUNDS || rounds > (unsigned
int)MAX_ROUNDS)
+
+               /* FIXME - Comparison between a signed and unsigned it
+
+               QUESTION: Do we expect ever in the lifetime of 'rounds that
+               the value of rounds will be negative? If not then it should
+               be a unsigned int.
+
+               QUESTION: What is the behind using a enum for 'MIN_ROUNDS'
+               and 'MAX_ROUNDS'? We take in unsigned int type. I do not see
+               a reason why we don't take in 'D, N and M' as const unsigned
+               ints. Are their values going to change during the lifetime of
+               the VariableROunds object?
+               */
+               if ((unsigned int) rounds < (unsigned int)MIN_ROUNDS ||
+                   (unsigned int)rounds > (unsigned int)MAX_ROUNDS) {
                        throw InvalidRounds(obj->AlgorithmName(), rounds);
+               }
                obj->UncheckedSetKey(dir, key, length, rounds);
        }
Index: simple.h
===================================================================
RCS file: /cvsroot/cryptopp/c5/simple.h,v
retrieving revision 1.8
diff -U2 -r1.8 simple.h
--- simple.h    18 Jul 2003 21:33:18 -0000      1.8
+++ simple.h    3 Nov 2003 05:13:39 -0000
@@ -90,13 +90,45 @@
                {InputRejected() : NotImplemented("BufferedTransformation: this
object doesn't allow input") {}};
 
+
        // shouldn't be calling these functions on this class
-       unsigned int Put2(const byte *begin, unsigned int length, int
messageEnd, bool blocking)
-               {throw InputRejected();}
+       unsigned int Put2(const byte *begin,
+                         unsigned int length,
+                         int messageEnd,
+                         bool blocking)
+         {
+           throw InputRejected();
+           /* FIXME: If we are throwing an exception this function should
+              be a 'void' type. */
+           return 0;
+         }
+       
        bool IsolatedFlush(bool, bool) {return false;}
-       bool IsolatedMessageSeriesEnd(bool) {throw InputRejected();}
+       bool IsolatedMessageSeriesEnd(bool) {
+         throw InputRejected();
+         /* FIXME: If we are throwing an exception this function should
+            be a 'void' type. */
+         return false;
+       }
+
+       unsigned int ChannelPut2(const std::string &channel,
+                                const byte *begin,
+                                unsigned int length,
+                                int messageEnd,
+                                bool blocking)
+         {
+           throw InputRejected();
+           /* FIXME: If we are throwing an exception this function should
+              be a 'void' type. */
+           return 0;
+         }
 
-       unsigned int ChannelPut2(const std::string &channel, const byte
*begin, unsigned int length, int messageEnd, bool blocking)
-               {throw InputRejected();}
-       bool ChannelMessageSeriesEnd(const std::string &, int, bool) {throw
InputRejected();}
+       bool ChannelMessageSeriesEnd(const std::string &,
+                                    int, bool)
+         {
+           throw InputRejected();
+           /* FIXME: If we are throwing an exception this function should
+              be a 'void' type. */
+           return false;
+         }
 };
 
cvs server: Diffing TestVectors

Stephen
-- 
Stephen Torri
GPG Key: http://www.cs.wustl.edu/~storri/storri.asc
-- 
Stephen Torri
GPG Key: http://www.cs.wustl.edu/~storri/storri.asc

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to