Open Bug 1523786 Opened 7 years ago Updated 4 years ago

NSIS plugins could overflow string stack entry

Categories

(Firefox :: Installer, defect, P3)

defect

Tracking

()

People

(Reporter: agashlin, Unassigned)

Details

Several NSIS plugins that derived from ApplicationID share this struct:

typedef struct _stack_t {
  struct _stack_t *next;
  TCHAR text[MAX_PATH];
} stack_t;

This is in ApplicationID, CertCheck, CityHash (with MAX_STRLEN), ExecInExplorer, and ServicesHelper.

In ExDLL there is a similar struct with:

TCHAR text[1]; // this should be the length of string_size

This is meant to be used to vary the size based on the string_size arg to the plugin entry point. Instead these plugins statically set the size to MAX_PATH or MAX_STRLEN. However they still add the size of the string when allocating in pushstring():

th=(stack_t*)GlobalAlloc(GPTR, sizeof(stack_t) + len);
lstrcpyn(th->text, str, len);

len is a number of characters, but it is also being used here as a number of bytes, so lstrcpyn could write past the buffer if len is long enough. ApplicationID, CertCheck, ExecInExplorer, and ServicesHelper have this issue, CityHash properly multiplies by sizeof(TCHAR).

I don't know for certain of any issues this causes, because len seems to not be set too high. But it might be worthwhile cleaning up.

Priority: -- → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.