Skip to content

Conversation

@yuwata
Copy link
Member

@yuwata yuwata commented Feb 16, 2019

Hopefully fixes one of issues in #11738.

@yuwata
Copy link
Member Author

yuwata commented Feb 16, 2019

cc @mrc0mmand.

@mrc0mmand
Copy link
Member

It indeed does, thanks!

296/462 test-socket-util                        OK       0.27 s

@yuwata
Copy link
Member Author

yuwata commented Feb 16, 2019

Hmm, the issue seems to be also false-positive...

r = safe_atou(v[1], &group);
if (r < 0)
return r;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's a good idea to replace sscanf() with something that has more strict semantics. But instead of strv_split() I'd propose using extract_first_word() to get the first word, and then safe_atou() directly on what remains. That way we don't bother with allocating an strv array that we actually don't really care much about.

@yuwata
Copy link
Member Author

yuwata commented Feb 18, 2019

Updated. Now extract_first_word() is used. PTAL.

@yuwata yuwata force-pushed the fix-11738-socket-util branch from ffa9b17 to 2700785 Compare February 18, 2019 23:23
@yuwata yuwata changed the title socket-util: re-implement socket_address_parse_netlink() by using strv_split() socket-util: re-implement socket_address_parse_netlink() by using extract_first_word() Feb 19, 2019
@yuwata yuwata force-pushed the fix-11738-socket-util branch from 2700785 to 12fb22f Compare February 19, 2019 21:18
return -EINVAL;

word = mfree(word);
r = extract_first_word(&s, &word, NULL, 0);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, for the second word, we can just use s directly; after all, there can only be one word left. Hence, instead of calling into extract_first_word() a second time, let's just use s right away. (note that extract_first_word() will not just return the first word, but advance s to the next word, skipping whitespace between the two words, hence this is perfect for this usecase)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds simpler, but currently it supports trailing white spaces. Simply passing the remaining string to safe_atou() drops the functionality. But I am not sure whether such a functionality is necessary or not. I will check all usecases later. Thanks.

@poettering poettering added the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Feb 20, 2019
…ract_first_word()

This drops support of trailing white space when a multicast group is
specified.

Fixes one of issues in systemd#11738.
@yuwata yuwata force-pushed the fix-11738-socket-util branch from 12fb22f to 4daa49d Compare February 21, 2019 05:59
@yuwata
Copy link
Member Author

yuwata commented Feb 21, 2019

Updated. Now the support of trailing white space when a multicast group is specified is dropped. Strictly speaking, this breaks backward compatibility of ListenNetlink=. However, e.g., IODeviceWeight= neither support trailing white space. So, I hope it is rare this causes problems in existing systems. PTAL.

@yuwata yuwata removed the reviewed/needs-rework 🔨 PR has been reviewed and needs another round of reworks label Feb 21, 2019
@poettering
Copy link
Member

ah, the trailing whitespace issues are interesting. I wonder if we maybe should change safe_atou() and friends to ignore trailing whitespace (it already ignores leading whitespace after all).

@poettering poettering merged commit 528a74a into systemd:master Feb 21, 2019
@yuwata yuwata deleted the fix-11738-socket-util branch February 21, 2019 10:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

3 participants