New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
procd: make mDNS TXT record parsing more solid #15331
Conversation
Clean results here. Tested on v23.05.3. Before you merge, could you also consider another commit to tackle pr 10715 - that's been waiting for years and is a really nice cosmetic fix in this code block also. Edit: hang on... something isn't right |
@systemcrash mh? tell me Also can you provide the combo you are using if it's ok to give? |
Sorry, false alarm. All is well. zero length entries are filtered out :D |
mDNS broadcast can't accept empty TXT record and would fail registration. Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record. Example: procd_add_mdns "blah" \ "tcp" "50" \ "1" \ "" \ "3" Produce: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } } The middle empty TXT record should never be included as it's empty. This can happen with scripts that make fragile parsing and include variables even if they are empty. Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones. The fixed JSON is the following: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } } Fixes: b0d9dcf ("procd: update to latest git HEAD") Reported-by: Paul Donald <newtwen@gmail.com> Link: openwrt#15331 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
8832c49
to
864346e
Compare
mDNS broadcast can't accept empty TXT record and would fail registration. Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record. Example: procd_add_mdns "blah" \ "tcp" "50" \ "1" \ "" \ "3" Produce: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } } The middle empty TXT record should never be included as it's empty. This can happen with scripts that make fragile parsing and include variables even if they are empty. Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones. The fixed JSON is the following: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } } Fixes: b0d9dcf ("procd: update to latest git HEAD") Reported-by: Paul Donald <newtwen@gmail.com> Link: openwrt#15331 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
864346e
to
9fbc81f
Compare
mDNS broadcast can't accept empty TXT record and would fail registration. Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record. Example: procd_add_mdns "blah" \ "tcp" "50" \ "1" \ "" \ "3" Produce: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } } The middle empty TXT record should never be included as it's empty. This can happen with scripts that make fragile parsing and include variables even if they are empty. Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones. The fixed JSON is the following: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } } Fixes: b0d9dcf ("procd: update to latest git HEAD") Reported-by: Paul Donald <newtwen@gmail.com> Link: openwrt#15331 Link: openwrt#15331 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
1bc03b5
to
864346e
Compare
mDNS broadcast can't accept empty TXT record and would fail registration. Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record. Example: procd_add_mdns "blah" \ "tcp" "50" \ "1" \ "" \ "3" Produce: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } } The middle empty TXT record should never be included as it's empty. This can happen with scripts that make fragile parsing and include variables even if they are empty. Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones. The fixed JSON is the following: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } } Fixes: b0d9dcf ("procd: update to latest git HEAD") Reported-by: Paul Donald <newtwen@gmail.com> Link: openwrt#15331 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
864346e
to
4b04304
Compare
mDNS broadcast can't accept empty TXT record and would fail registration. Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record. Example: procd_add_mdns "blah" \ "tcp" "50" \ "1" \ "" \ "3" Produce: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } } The middle empty TXT record should never be included as it's empty. This can happen with scripts that make fragile parsing and include variables even if they are empty. Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones. The fixed JSON is the following: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } } Fixes: b0d9dcf ("procd: update to latest git HEAD") Reported-by: Paul Donald <newtwen@gmail.com> Link: #15331 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> (cherry picked from commit 4b04304)
mDNS broadcast can't accept empty TXT record and would fail registration. Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record. Example: procd_add_mdns "blah" \ "tcp" "50" \ "1" \ "" \ "3" Produce: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } } The middle empty TXT record should never be included as it's empty. This can happen with scripts that make fragile parsing and include variables even if they are empty. Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones. The fixed JSON is the following: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } } Fixes: b0d9dcf ("procd: update to latest git HEAD") Reported-by: Paul Donald <newtwen@gmail.com> Link: #15331 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> (cherry picked from commit 4b04304)
Also backported to 23.05 and 22.03 :D |
[ -z "$txt" ] && continue | ||
txt_count=$((txt_count+1)) | ||
[ $txt_count -eq 1 ] && json_add_array txt | ||
json_add_string "" "$txt" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sigh:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pprindeville can you better explain?
After the fact, but... LGTM |
mDNS broadcast can't accept empty TXT record and would fail registration. Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record. Example: procd_add_mdns "blah" \ "tcp" "50" \ "1" \ "" \ "3" Produce: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } } The middle empty TXT record should never be included as it's empty. This can happen with scripts that make fragile parsing and include variables even if they are empty. Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones. The fixed JSON is the following: { "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } } Fixes: b0d9dcf ("procd: update to latest git HEAD") Reported-by: Paul Donald <newtwen@gmail.com> Link: openwrt#15331 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com>
@pprindeville sorry for not tagging :( i looked like a straight bug and a very safe fix |
mDNS broadcast can't accept empty TXT record and would fail registration.
Current procd_add_mdns_service checks only if the first passed arg is empty but don't make any verification on the other args permittins insertion of empty values in TXT record.
Example:
Produce:
{ "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "", "3" ] } }
The middle empty TXT record should never be included as it's empty.
This can happen with scripts that make fragile parsing and include variables even if they are empty.
Prevent this and make the TXT record more solid by checking every provided TXT record and include only the non-empty ones.
The fixed JSON is the following:
{ "blah_50": { "service": "_blah._tcp.local", "port": 50, "txt": [ "1", "3" ] } }
Fixes: b0d9dcf ("procd: update to latest git HEAD")
Reported-by: Paul Donald newtwen@gmail.com