bitcoin/short_channel_id: short_channel_id_from_str accepts trailing garbage, negative numbers, and whitespace
Les mainteneurs répondent en général sous 2 jours
Évaluation
- Difficulté
- 2/5
- Temps estimé
- 1-3 heures
- Accessibilité débutants
- 83/100
- Type d'issue
- Bug
- Clarté
- Clairement spécifiée
- Activité
- Active
- Stack technique
- c
- Domaine
- backend-api-design
Piste de recherche
Commencez par short_channel_id_from_str() dans bitcoin/short_channel_id.c et suivez short_channel_id_dir_from_str(), qui délègue à cette fonction. Vérifiez comment le parseur actuel traite les exemples invalides fournis, puis assurez-vous que l’analyse rejette les entrées mal formées tout en acceptant le format décimal spécifié à trois composants. Le travail est terminé lorsque les exemples comportant des caractères finaux, des valeurs négatives, des signes ou des espaces sont rejetés.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
Issue and Steps to Reproduce
short_channel_id_from_str() in bitcoin/short_channel_id.c parses short channel ID strings using sscanf:
bool short_channel_id_from_str(const char *str, size_t strlen,
struct short_channel_id *dst)
{
u32 blocknum, txnum;
u16 outnum;
if (sscanf(str, "%ux%ux%hu", &blocknum, &txnum, &outnum) == 3)
return mk_short_channel_id(dst, blocknum, txnum, outnum);
return false;
}
This implementation allows several invalid string formats to succeed:
- Trailing garbage / unparsed characters:
sscanfdoes not check if the entire buffer length (strlen) is consumed. Strings such as"1x2x3garbage","1x2x3/0","1x2x3x4", or"1x2x3 4"successfully returntruewith validdstfilled from the initial match. - Negative outnums:
%huaccepts negative numbers (e.g."-1"), parsing them as65535((u16)-1). Inmk_short_channel_id(),(outnum & 0xFFFF) != outnumevaluates to65535 != 65535which is false, so"1x2x-1"is accepted as valid channel output 65535. - Leading / internal whitespace and signs:
sscanfskips whitespace before numeric conversions and parses leading+signs, allowing strings like" 1x2x3","1x 2x3", or"+1x2x3". short_channel_id_dir_from_strpollution: Becauseshort_channel_id_dir_from_strdelegates toshort_channel_id_from_str(str, slash - str, ...), strings like"1x2x3garbage/0"are also parsed without error.
Steps to reproduce:
struct short_channel_id scid;
assert(short_channel_id_from_str("1x2x3garbage", strlen("1x2x3garbage"), &scid) == false); // Fails (returns true)
assert(short_channel_id_from_str("1x2x-1", strlen("1x2x-1"), &scid) == false); // Fails (returns true)
Expected behavior:
Per BOLT 7, a short channel ID is uniquely represented by three decimal components delimited by 'x': <blocknum>x<txnum>x<outnum>. short_channel_id_from_str() should strictly parse the entire provided string and reject trailing garbage, negative values, signs, and whitespace.
getinfo output
N/A (observed in bitcoin/short_channel_id.c across all CLN versions).
- Langage dominant
- C
- Étoiles
- 3.1k
- Forks
- 1k
- Merge moyen
- 4 j 21 h
- PR mergées (30 j)
- 21
Préparer son environnement
- Fournit un Dockerfile ou un fichier Docker Compose
- Propose un modèle de pull request
- Aucun guide de contribution
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de ElementsProject/lightning
-
common/amount: parse_amount_sat misparses sub-satoshi msat with leading zero and accepts invalid suffixesPeut-être pris @bhuvan-somisetty l’a pris il y a 10 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
ElementsProject/lightning#9674 ·
Les mainteneurs répondent en général sous 2 jours
-
createrune accepts an empty restriction, after which showrunes crashes lightningd (SIGSEGV)Peut-être pris @amartya1523 l’a pris il y a 4 jours. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
ElementsProject/lightning#9673 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 72/100
ElementsProject/lightning#9671 ·
Les mainteneurs répondent en général sous 2 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 66/100
ElementsProject/lightning#9634 ·
Les mainteneurs répondent en général sous 2 jours
-
plugins/recover: missing comma in nodes_for_gossip concatenates two bootstrap addresses into invalid addressPeut-être pris @bhuvan-somisetty l’a pris il y a 23 jours. Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 88/100
ElementsProject/lightning#9630 ·
Les mainteneurs répondent en général sous 2 jours
Toutes les issues de ElementsProject/lightning
Issues similaires
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 75/100
micropython/micropython#19906 ·
Les mainteneurs répondent en général sous 1 jour
-
QOI: QOI_OP_RUN does not update the previously seen pixels, corrupting qoi_test_images/edgecase.qoiPeut-être pris @manit2004 l’a pris aujourd’hui. Ouverte
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
python-pillow/Pillow#10452 · 4 commentaires ·
Les mainteneurs répondent en général sous 1 jour
-
Difficulté 1/5 Moins d'une heure Accessibilité débutants 75/100
Les mainteneurs répondent en général sous 10 jours
-
Difficulté 2/5 1-3 heures Accessibilité débutants 77/100
JPHutchins/dynamic-call-tree-resolution#349 ·
Les mainteneurs répondent en général sous 1 jour
-
bug
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
Les mainteneurs répondent en général sous 1 jour