Re: FW: gnokii-corrupt file download on windows

Daniele Forsi <[email protected]>
Newsgroups gmane.linux.drivers.gnokii
Message-ID <CAN_we7PBzuOXm=Cjqpzjo8yg7HWRr5u_hynLH4R9w9FdZEx2Ag@mail.gmail.com>
2013/3/1 Stitzinger, Thomas <[email protected]>:
> Hi
>
> First of all my answers to your question:
>
> #1) Well phonebook and SMS functionality is working fine
>
> #2)The driver was installed from the Win7 automatically when I plugged in my
> phone. It roots an USB port to a COM Port and uses a FBUS (FieldBUS)
> protocol as far as I can see.  Here is  few information about the driver:
> Driver Provider: Prolific
>
> Driver Date:26.07.2012
>
> Driver Version:3.4.36.247
>
> Digital Signer: Microsoft Windows Hardware Compatibility Publisher
>
>
>
>
>
> Now I analyzed the problem in more detail. I compared the files (the good
> one and the corrupted).
>
> The file which was downloaded from the phone with gnokii was slightly
> different and it was a little bit longer than the good file.
>
> I figured out that all a 0X0A bytes in the file have been shifted to a two
> byte (0X0D, 0X0A) sequence.

good catch, we're opening the file in "w" mode which for Windows means
"text mode write", so we need to modify some occurrences of fopen() to
make it work with "binary files"

in your case it's at line 274 of gnokii/gnokii-file.c
f = fopen(filename2, "w");
should be changed to
f = fopen(filename2, "wb");

there are other occurrences of fopen(), some already have "b" and some
probably shouldn't be changed because they actually use text files
$ grep fopen . -r --include=*.c
./xgnokii/xgnokii_speed.c:	if ((f = fopen(fileName, "r")) == NULL) {
./xgnokii/xgnokii_speed.c:	if ((f = fopen(name, "w")) == NULL) {
./xgnokii/xgnokii_speed.c:	if ((f = fopen(exportDialogData.fileName,
"r")) != NULL) {
./xgnokii/xgnokii_cfg.c:	if ((file = fopen(rcfile, "r")) == NULL) {
./xgnokii/xgnokii_cfg.c:	if ((file = fopen(rcfile, "w")) == NULL) {
./xgnokii/xgnokii_sms.c:	if ((f = fopen(mailbox_name, "a")) == NULL) {
./xgnokii/xgnokii_dtmf.c:	if ((f = fopen(fileName, "r")) == NULL) {
./xgnokii/xgnokii_dtmf.c:	if ((f = fopen(saveFileName, "w")) == NULL) {
./xgnokii/xgnokii_dtmf.c:	if ((f = fopen(saveFileName, "r")) != NULL) {
./xgnokii/xgnokii_contacts.c:	if ((f = fopen(name, "w")) == NULL) {
./xgnokii/xgnokii_contacts.c:	if ((f =
fopen(exportDialogData.fileName, "r")) != NULL) {
./xgnokii/xgnokii_contacts.c:	if ((f = fopen(fileName, "r")) == NULL) {
./xgnokii/xgnokii_logos.c:	if ((f = fopen(exportDialogData.fileName,
"r")) != NULL) {
./xgnokii/xgnokii_logos.c:	if ((f = fopen(fileName, "r")) == NULL) {
./testsuite/dump-vcard.c:		f = fopen (argv[1], "r");
./gnokii/gnokii-file.c:		f = fopen(filename2, "w");
./gnokii/gnokii-file.c:			f = fopen(filename2, "w");
./gnokii/gnokii-file.c:				f = fopen(filename2, "w");
./gnokii/gnokii-file.c:	f = fopen(optarg, "rb");
./gnokii/gnokii-todo.c:	f = fopen(optarg, "r");
./gnokii/gnokii-ringtone.c:		if ((f = fopen(filename, "wb")) == NULL) {
./gnokii/gnokii-ringtone.c:		if ((f = fopen(filename, "rb")) == NULL) {
./gnokii/gnokii-sms.c:	if ((output = fopen(buf, "r")) != NULL) {
./gnokii/gnokii-sms.c:	if ((output = fopen(buf, "w+")) == NULL) {
./gnokii/gnokii-calendar.c:	f = fopen(optarg, "r");
./gnokii/gnokii.c:	if ((logfile = fopen(logname, "a")) == NULL) {
./gnokii/gnokii-utils.c:		file = fopen(filename, "a");
./gnokii/gnokii-utils.c:		file = fopen(filename, "w");
./gnokii/gnokii-utils.c:		file = fopen(filename, "a");
./gnokii/gnokii-utils.c:		file = fopen(filename, "w");
./common/phones/fake.c:	f = fopen(path, "r");
./common/gsm-auth.c:	f = fopen(path, "r");
./common/gsm-filetypes.c:	file = fopen(filename, "rb");
./common/gsm-filetypes.c:	file = fopen(filename, "wb");
./common/gsm-filetypes.c:	file = fopen(filename, "rb");
./common/gsm-filetypes.c:		file = fopen(filename, "wb");
./common/localcharset.c:      if (file_name == NULL || (fp = fopen
(file_name, "r")) == NULL)
./common/cfgreader.c:	if ((handle = fopen(filename, "r")) == NULL) {
./smsd/smsd.c:  else if ((f = fopen (smsdConfig.logFile, "a")) == NULL)
./smsd/file.c:    if ((smsFile = fopen (buf->str, "r")) == NULL)

-- 
Daniele Forsi
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.