Alternative map sorting
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 25/100
- Tipo di issue
- Funzionalità
- Chiarezza
- Da chiarire
- Stato di attività
- Ferma
- Stack tecnologico
- c
- Ambito
- embedded-iot
Direzione di ricerca
Inizia da cborvalidation.c intorno alla riga 475 e rivedi i flag esistenti per l’ordinamento delle mappe e l’unicità. Chiarisci se l’ordinamento alternativo debba sostituire o integrare il comportamento attuale, quindi definisci l’ordine previsto, la gestione delle chiavi e il comportamento in caso di chiavi duplicate; il completamento dipende dall’accordo sul design e sull’ambito dell’implementazione.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Hello,
I've been looking into the CBOR validator and how maps are considered as sorted or not. In another project, I have previously been using another serialization standard that strictly defines maps in another way. Such as keys must only be strings, keys must be stored in lexicographical order and that no duplicates are allowed. Now we are looking into changing to cbor.
The CBOR specification does not strictly specifies what an ordered map is, but recommends that they should also be sorted in length. Meaning that "aa" > "b".
The alternatives are:
- Change sorting specification in our protocol (to order the fields like CBOR specification recommends)
- Not having sorted maps
- Finding/adapting a cbor library to allow for alternative sorting
Sorting is nice since is allows for linear parsing. Since we rely on this, we cannot directly swap to cbor. I would like to start a discussion of supporting an alternative sorting in tinycbor.
Wrote a short proof of concept for this (removes old sorting behavior) cborvalidation.c:475:
if (flags & CborValidateMapIsSorted) {
if (previous) {
uint64_t len1, len2;
const uint8_t *ptr;
/* extract the two lengths */
ptr = previous;
_cbor_value_extract_number(&ptr, it->parser->end, &len1);
ptr = current;
_cbor_value_extract_number(&ptr, it->parser->end, &len2);
size_t bytelen1 = (size_t)(previous_end - previous);
size_t bytelen2 = (size_t)(it->ptr - current);
/*
* Offset of actual key value (not including type information) is bytelenX - lenX??
* What if key value is indefinite??
*/
int r = memcmp(&previous[bytelen1 - len1], ¤t[bytelen2 - len2], len1 <= len2 ? len1 : len2);
if (r == 0 && len1 != len2)
r = len1 < len2 ? -1 : +1;
if (r > 0)
return CborErrorMapNotSorted;
if (r == 0 && (flags & CborValidateMapKeysAreUnique) == CborValidateMapKeysAreUnique)
return CborErrorMapKeysNotUnique;
}
Would it be possible to add a flag that would allow for this kind of sorting?
- Lingua principale
- C
- Stelle
- 634
- Fork
- 222
- Merge medio
- 1g 25m
- PR unite (30g)
- 2
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Nessun modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di intel/tinycbor
-
CborValidateTagUse rejects valid tag 1 (epoch) with a floating-point value, and restricts tags 21-23 too muchForse già presa @thiagomacieira l’ha presa 6 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 45/100
-
CBOR validation not worksAperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 38/100
Tutte le issue di intel/tinycbor
Issue simili
-
rc_runtime_activate_richpresence leaves a half-initialised entry when the buffer allocation failsAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 88/100
RetroAchievements/rcheevos#558 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
libsdl-org/SDL#16464 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
-
chore(gateway): emit INFO budget reserved/settled logs for proactivity v2 (chip task_2855f4ec)Forse già presa Una pull request collegata a questa issue è aperta o già unita. Apertabackend
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
BasedHardware/omi#20940 ·
I maintainer di solito rispondono entro 1 giorno