Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

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

Abierto
#49 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
3/5
Tiempo estimado
1-2 días
Aptitud para principiantes
55/100
Tipo de issue
Error
Claridad
Bastante claro
Estado de actividad
Tranquilo
Stack tecnológico
cpp
Área
data

Línea de trabajo

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.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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)
Lenguaje dominante
C++
Estrellas
406
Forks
74
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

No hay ninguna guía de contribución indexada para este repositorio

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de nmwsharp/happly

Todos los issues de nmwsharp/happly

Issues similares

Más issues de C++

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.