summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-15 20:29:09 +0000
committerTzafrir Cohen <tzafrir.cohen@xorcom.com>2012-03-15 20:29:09 +0000
commit00378c0a7d0ef13ba02391176f9cf5db3a8f4dc3 (patch)
treeba3fa5e6c9b25a083455a9fde7c2c1211eca8486
parent877eb9940c0217e025cf9d72b8e33502ad3c49d4 (diff)
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@xorcom.com> Acked-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com> git-svn-id: http://svn.asterisk.org/svn/dahdi/tools/trunk@10491 a0bf4364-ded3-4de4-8d8a-66a801d63aff
-rw-r--r--xpp/mpp.h2
-rw-r--r--xpp/mpptalk.c16
-rw-r--r--xpp/mpptalk_defs.h2
3 files changed, 18 insertions, 2 deletions
diff --git a/xpp/mpp.h b/xpp/mpp.h
index 23a0ce9..e6b8e3a 100644
--- a/xpp/mpp.h
+++ b/xpp/mpp.h
@@ -83,7 +83,7 @@ struct capkey {
} PACKED;
struct extrainfo {
- char text[24];
+ char text[EXTRAINFO_SIZE];
} PACKED;
struct mpp_header {
diff --git a/xpp/mpptalk.c b/xpp/mpptalk.c
index a8bf12a..6b33743 100644
--- a/xpp/mpptalk.c
+++ b/xpp/mpptalk.c
@@ -366,7 +366,17 @@ int mpp_extrainfo_get(struct astribank_device *astribank, struct extrainfo *info
}
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_astribank_status(struct astribank_device *astribank, FILE *fp)
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)
diff --git a/xpp/mpptalk_defs.h b/xpp/mpptalk_defs.h
index e38f381..bc0b83b 100644
--- a/xpp/mpptalk_defs.h
+++ b/xpp/mpptalk_defs.h
@@ -108,4 +108,6 @@ enum dev_dest {
DEST_EEPROM = 0x02,
};
+#define EXTRAINFO_SIZE 24
+
#endif /* MPPTALK_DEFS_H */