micropython/shared/memzip
Jim Mussared 5015779a6f py/builtinevex: Handle invalid filenames for execfile.
If a non-string buffer was passed to execfile, then it would be passed
as a non-null-terminated char* to mp_lexer_new_from_file.

This changes mp_lexer_new_from_file to take a qstr instead (as in almost
all cases a qstr will be created from this input anyway to set the
`__file__` attribute on the module).

This now makes execfile require a string (not generic buffer) argument,
which is probably a good fix to make anyway.

Fixes issue #12522.

This work was funded through GitHub Sponsors.

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
2023-10-12 15:17:59 +11:00
..
README.md all: Update to point to files in new shared/ directory. 2021-07-12 17:08:10 +10:00
import.c shared: Introduce new top-level dir and move 1st party lib code there. 2021-07-12 17:07:36 +10:00
lexermemzip.c py/builtinevex: Handle invalid filenames for execfile. 2023-10-12 15:17:59 +11:00
make-memzip.py all: Fix various Python coding inconsistencies found by ruff. 2023-05-02 16:14:45 +10:00
memzip.c shared: Introduce new top-level dir and move 1st party lib code there. 2021-07-12 17:07:36 +10:00
memzip.h shared: Introduce new top-level dir and move 1st party lib code there. 2021-07-12 17:07:36 +10:00

README.md

MEMZIP - a simple readonly file system

memzip takes a zip file which is comprised of uncompressed files and and presents it as a filesystem, allowing Python files to be imported.

The script make-memzip.py takes a directory name and will create a zip file containing uncompressed files found in the directory. It will then generate a C file which contains the data from the zip file.

A typical addition to a makefile would look like:

SRC_C += \
    shared/memzip/import.c \
    shared/memzip/lexermemzip.c \
    shared/memzip/memzip.c \

OBJ += $(BUILD)/memzip-files.o

MAKE_MEMZIP = ../shared/memzip/make-memzip.py

$(BUILD)/memzip-files.o: $(BUILD)/memzip-files.c
    $(call compile_c)

$(BUILD)/memzip-files.c: $(shell find ${MEMZIP_DIR} -type f)
    @$(ECHO) "Creating $@"
    $(Q)$(PYTHON) $(MAKE_MEMZIP) --zip-file $(BUILD)/memzip-files.zip --c-file $@ $(MEMZIP_DIR)