adept_loan_mgt is dumping endless of space characters #3

Closed
opened 2024-03-29 23:20:09 +01:00 by Antoine · 4 comments

adept_loan_mgt is not working with the latest release (0d77cf5). When run, it dumps endless space characters. It has to be stopped by Ctrl-C. In fact it writes 7 spaces (0x20) followed by "ID" (0x49 0x44) followed by endless spaces (0x20):

$ ./adept_loan_mgt > out
^C
$ hexdump -C out 
00000000  20 20 20 20 20 20 20 49  44 20 20 20 20 20 20 20  |       ID       |
00000010  20 20 20 20 20 20 20 20  20 20 20 20 20 20 20 20  |                |
*
0cf7b000

The only 2 options which work are --help and --version.

adept_loan_mgt is not working with the latest release (0d77cf5). When run, it dumps endless space characters. It has to be stopped by Ctrl-C. In fact it writes 7 spaces (0x20) followed by "ID" (0x49 0x44) followed by endless spaces (0x20): ``` $ ./adept_loan_mgt > out ^C $ hexdump -C out 00000000 20 20 20 20 20 20 20 49 44 20 20 20 20 20 20 20 | ID | 00000010 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 | | * 0cf7b000 ``` The only 2 options which work are `--help` and `--version`.
Owner

Sorry for the delay, I didn't get notification for this ticket.

I tried both compiled utils, AppImage and own compilation but it's OK on my side.
What is your system configuration ?
Can you upload files inside your ~/.config/adept/loans ?

Thnaks

Sorry for the delay, I didn't get notification for this ticket. I tried both compiled utils, AppImage and own compilation but it's OK on my side. What is your system configuration ? Can you upload files inside your ~/.config/adept/loans ? Thnaks
Author

I think I understand why there is a bug.

For an unknown reason, the loan has no name:

<name></name>

This has an impact on adept_loan_mgt.cpp and more precisely at line 243. As the loan has no name, maxSizeBookName = 0 but this is an unsigned int. At line 243 we have:

fillBookName = (maxSizeBookName - 4) / 2;

The unsigned int cannot be negative and we end-up with an integer underflow. The result is fillBookName = 2147483646.

You can easily solve the issue by replacing line 243 by:

fillBookName = ((int) maxSizeBookName - 4) / 2;

You do not have the integer underflow anymore but you end up with fillBookName = -2 which might not be wanted...

The question I do not have an answer is: Is it normal not to have a name in a loan?

I think I understand why there is a bug. For an unknown reason, the loan has no name: ``` <name></name> ``` This has an impact on adept_loan_mgt.cpp and more precisely at [line 243](https://forge.soutade.fr/soutade/libgourou/src/commit/f60abf04d828558a36249bd37b45c78f04158e8f/utils/adept_loan_mgt.cpp#L243). As the loan has no name, `maxSizeBookName = 0` but this is an `unsigned int`. At line 243 we have: ``` fillBookName = (maxSizeBookName - 4) / 2; ``` The `unsigned int` cannot be negative and we end-up with an integer underflow. The result is `fillBookName = 2147483646`. You can easily solve the issue by replacing line 243 by: ``` fillBookName = ((int) maxSizeBookName - 4) / 2; ``` You do not have the integer underflow anymore but you end up with `fillBookName = -2` which might not be wanted... The question I do not have an answer is: Is it normal not to have a name in a loan?
Owner

Thanks for investigating it !

I created a branch loan_empty_name to manage names with size < 4. Can you validate it before merge ?

If you can also send me .acsm file to check why there is no name, it would be nice.

Thanks for investigating it ! I created a branch [loan_empty_name](https://forge.soutade.fr/soutade/libgourou/src/branch/loan_empty_name) to manage names with size < 4. Can you validate it before merge ? If you can also send me .acsm file to check why there is no name, it would be nice.
soutade self-assigned this 2024-04-14 21:24:02 +02:00
soutade added reference loan_empty_name 2024-04-14 21:24:11 +02:00
Author

I confirm the loan_empty_name branch works as expected. "No name" appears.
Thank you for the fix.

I confirm the loan_empty_name branch works as expected. "No name" appears. Thank you for the fix.
Sign in to join this conversation.
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: soutade/libgourou#3
No description provided.