sbabic / libubootenv

Generic library and tools to access and modify U-Boot environment from User Space
72 stars 39 forks source link

issue with LINE_LENGTH in libuboot_load_file() #21

Closed lakabd closed 1 week ago

lakabd commented 2 years ago

Hi, In uboot_env.c the libuboot_load_file() function is used to load and parse the default environment file passed with -f option. The issue I encountered, is that this function will read the file line by line in chunks of max LINE_LENGTH characters (to extract the environment variables from it), and if a line in the provided file exceeds this limit, the environment will be corrupted !!!

Two problems with this: firstly there is no warning that is printed. Normally the function should detect this and return error when encountered, to avoid corrupted environment. (I'll be happy to submit a patch for this)

Secondly, the value of LINE_LENGTHis set at compile time, and cannot be modified later. Maybe it could be interesting to have an additional option that goes with the -f option to specify the max line length.

If this is viewed as not a bug by the maintainer, I would suggest at least to add a warning about this limitation in the README or the usage of the cmd.

The default value for LINE_LENGTHis 1024bytes, which is defined as a macro. 1024Bcan be easily exceeded in some cases when defining scripts e.g. Recovery/Prod scripts.

Kind regards Abder

sbabic commented 1 week ago

commit 123383 has increased the size to 2048.