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.astersk.org/svn/dahdi/tools/trunk@10491 17933a7a-c749-41c5-a318-cba88f637d49
This commit is contained in:
parent
949ea4ca9f
commit
971a45a807
@ -83,7 +83,7 @@ struct capkey {
|
||||
} PACKED;
|
||||
|
||||
struct extrainfo {
|
||||
char text[24];
|
||||
char text[EXTRAINFO_SIZE];
|
||||
} PACKED;
|
||||
|
||||
struct mpp_header {
|
||||
|
@ -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)
|
||||
|
@ -108,4 +108,6 @@ enum dev_dest {
|
||||
DEST_EEPROM = 0x02,
|
||||
};
|
||||
|
||||
#define EXTRAINFO_SIZE 24
|
||||
|
||||
#endif /* MPPTALK_DEFS_H */
|
||||
|
Loading…
Reference in New Issue
Block a user