[dahdi-commits] tzafrir: branch tools/2.5 r10507 - /tools/branches/2.5/xpp/

SVN commits to the DAHDI project dahdi-commits at lists.digium.com
Thu Mar 15 16:17:14 CDT 2012


Author: tzafrir
Date: Thu Mar 15 16:17:10 2012
New Revision: 10507

URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=10507
Log:
xpp: clean 'Extrainfo' EEPROM field

* Extrainfo field contains junk data
* Caused by:
  - The field is initialized to 0xFF values
  - There was no null termination (and no room to add it)
* New code:
  - Ensure that show_extrainfo() have null termination even if EEPROM
    field is full.
  - Replace trailing 0xFF characters with '\0' when reading this field
  - Since our default burned EEPROM contain Extrainfo field full of
    0xFF characters, this would make them look as null filled.

Internal Issue-Id: #1341
Signed-off-by: Oron Peled <oron.peled at xorcom.com>
Acked-by: Tzafrir Cohen <tzafrir.cohen at xorcom.com>
Origin: http://svnview.digium.com/svn/dahdi?view=rev&rev=10491

Modified:
    tools/branches/2.5/xpp/mpp.h
    tools/branches/2.5/xpp/mpptalk.c
    tools/branches/2.5/xpp/mpptalk_defs.h

Modified: tools/branches/2.5/xpp/mpp.h
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/mpp.h?view=diff&rev=10507&r1=10506&r2=10507
==============================================================================
--- tools/branches/2.5/xpp/mpp.h (original)
+++ tools/branches/2.5/xpp/mpp.h Thu Mar 15 16:17:10 2012
@@ -83,7 +83,7 @@
 } PACKED;
 
 struct extrainfo {
-	char		text[24];
+	char		text[EXTRAINFO_SIZE];
 } PACKED;
 
 struct mpp_header {

Modified: tools/branches/2.5/xpp/mpptalk.c
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/mpptalk.c?view=diff&rev=10507&r1=10506&r2=10507
==============================================================================
--- tools/branches/2.5/xpp/mpptalk.c (original)
+++ tools/branches/2.5/xpp/mpptalk.c Thu Mar 15 16:17:10 2012
@@ -366,7 +366,17 @@
 	}
 	assert(reply->header.op == MPP_EXTRAINFO_GET_REPLY);
 	if(info) {
+		int i;
+
 		memcpy(info, (void *)&CMD_FIELD(reply, MPP, EXTRAINFO_GET_REPLY, info), sizeof(*info));
+		/*
+		 * clean non-printing characters
+		 */
+		for (i = sizeof(*info) - 1; i >= 0; i--) {
+			if (info->text[i] != (char)0xFF)
+				break;
+			info->text[i] = '\0';
+		}
 	}
 	free_command(reply);
 	return 0;
@@ -876,7 +886,11 @@
 
 void show_extrainfo(const struct extrainfo *extrainfo, FILE *fp)
 {
-	fprintf(fp, "Extrainfo:             : %s\n", (const char *)(extrainfo->text));
+	char	buf[EXTRAINFO_SIZE + 1];
+
+	memcpy(buf, extrainfo->text, EXTRAINFO_SIZE);
+	buf[EXTRAINFO_SIZE] = '\0';	/* assure null termination */
+	fprintf(fp, "Extrainfo:             : '%s'\n", buf);
 }
 
 int twinstar_show(struct astribank_device *astribank, FILE *fp)

Modified: tools/branches/2.5/xpp/mpptalk_defs.h
URL: http://svnview.digium.com/svn/dahdi/tools/branches/2.5/xpp/mpptalk_defs.h?view=diff&rev=10507&r1=10506&r2=10507
==============================================================================
--- tools/branches/2.5/xpp/mpptalk_defs.h (original)
+++ tools/branches/2.5/xpp/mpptalk_defs.h Thu Mar 15 16:17:10 2012
@@ -108,4 +108,6 @@
 	DEST_EEPROM	= 0x02,
 };
 
+#define	EXTRAINFO_SIZE	24
+
 #endif	/* MPPTALK_DEFS_H */




More information about the dahdi-commits mailing list