Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions sys/src/cmd/6l/obj.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define EXTERN
#include "l.h"
#include "../ld/elf.h"
#include "../ld/dwarf.h"
#include <ar.h>

#ifndef DEFAULT
Expand Down Expand Up @@ -854,6 +855,7 @@ ldobj(int f, long c, char *pn)
histgen++;
s->type = SFILE;
s->value = histgen;
dwarfaddfrag(s->value, s->name+1);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The call to dwarfaddfrag uses s->name+1 to skip the type prefix (typically 'z' or 'f'). While SFILE symbols in this context are expected to have such a prefix, if s->name were an empty string, this would result in an out-of-bounds read. Adding a check for the string length ensures robustness against malformed object files.

				if(s->name[0] != '\0')
					dwarfaddfrag(s->value, s->name+1);

}
if(histfrogp < MAXHIST) {
histfrog[histfrogp] = s;
Expand Down
Loading