Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Crashes when the number of properties is less than what the header defines

Aperta
#49 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Tranquilla
Stack tecnologico
cpp
Ambito
data

Direzione di ricerca

Start at the element-property loop that calls parseNext and inspect tokenSplit and parseNext together. Reproduce the supplied PLY example with fewer values than declared, then verify that the chosen bounds-checking behavior prevents an out-of-bounds access and handles the malformed row safely.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Properties are parsed with a loop that is repeated elem.properties.size() times, which is the number of properties the header says this element should have.

vector<string> tokens = tokenSplit(line);
size_t iTok = 0;
for (size_t iP = 0; iP < elem.properties.size(); iP++) {
  elem.properties[iP]->parseNext(tokens, iTok);
}

However if this element has less properties than the header defines, tokenSplit(line) returns a number of tokens less than elem.properties.size().

Then when we call parseNext, tokens[curEntry] is an out-of-bounds access and we crash when trying to create an istringstream from whatever garbage we read.

virtual void parseNext(const std::vector<std::string>& tokens, size_t& currEntry) override {
  data.emplace_back();
  std::istringstream iss(tokens[currEntry]);
  typename SerializeType<T>::type tmp; // usually the same type as T
  iss >> tmp;
  data.back() = tmp;
  currEntry++;
};

Here is an example file that will cause a crash:

ply
format ascii 1.0
element vertex 1
property float x
property float y
property char z
comment There are 3 properties but we provide only 2!
end_header
3 4 

Possible fixes:

  • Verify that the number of tokens matches the expected number of properties
  • In parseNext, ensure that currEntry is within tokens.size()
  • In parseNext, use tokens.at(currEntry)
Lingua principale
C++
Stelle
406
Fork
74
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di nmwsharp/happly

Tutte le issue di nmwsharp/happly

Issue simili

Altre issue su C++

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.