This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
SNMP lib warning fix
- From: Jonathan Larmour <jifl at eCosCentric dot com>
- To: eCos Patches List <ecos-patches at sources dot redhat dot com>
- Date: Tue, 25 Mar 2003 04:13:57 +0000
- Subject: SNMP lib warning fix
There's quite a few warnings about unused variables, but I'm going to
ignore those. However there was a warning about potentially undefined
behaviour, so I decided to fix that, just as a pre-emptive move.
Jifl
--
eCosCentric http://www.eCosCentric.com/ The eCos and RedBoot experts
--[ "You can complain because roses have thorns, or you ]--
--[ can rejoice because thorns have roses." -Lincoln ]-- Opinions==mine
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/lib/current/ChangeLog,v
retrieving revision 1.11
diff -u -5 -p -r1.11 ChangeLog
--- ChangeLog 28 Feb 2003 09:25:22 -0000 1.11
+++ ChangeLog 25 Mar 2003 04:12:50 -0000
@@ -1,5 +1,10 @@
+2003-03-24 Jonathan Larmour <jifl at eCosCentric dot com>
+
+ * src/keytools.c (decode_keychange): Avoid undefined behaviour.
+ (encode_keychange): Ditto.
+
2003-02-28 Andrew Lunn <andrew dot lunn at ascom dot ch>
* include/config.h: Make random use rand on FreeBSD.
* include/system.h: For FreeBSD include param.h so we get the aliases.
#Undefine printf so stdio.h will compile. printf is not used anywhere.
Index: src/keytools.c
===================================================================
RCS file: /cvs/ecos/ecos-opt/snmp/lib/current/src/keytools.c,v
retrieving revision 1.4
diff -u -5 -p -r1.4 keytools.c
--- src/keytools.c 3 Feb 2003 16:34:46 -0000 1.4
+++ src/keytools.c 25 Mar 2003 04:12:51 -0000
@@ -505,11 +505,12 @@ encode_keychange( oid *hashtype, u_int
*kcstring_len = (properlength*2);
kcstring += properlength;
nbytes = 0;
while ((int)(nbytes++) < properlength) {
- *kcstring++ = *kcstring ^ *newkey++;
+ u_char kcs = *kcstring;
+ *kcstring++ = kcs ^ *newkey++;
}
}
encode_keychange_quit:
if (rval != SNMPERR_SUCCESS) memset(kcstring, 0, *kcstring_len);
@@ -622,11 +623,12 @@ decode_keychange( oid *hashtype, u_int
memcpy(newkey, tmp_buf, properlength);
bufp = kcstring+properlength;
nbytes = 0;
while ((int)(nbytes++) < properlength) {
- *newkey++ = *newkey ^ *bufp++;
+ u_char nk = *newkey;
+ *newkey++ = nk ^ *bufp++;
}
}
decode_keychange_quit:
if (rval != SNMPERR_SUCCESS) {