public inbox for pmg-devel@lists.proxmox.com
 help / color / mirror / Atom feed
* [pmg-devel] [PATCH pmg-log-tracker] fix wrong QID argument handling
@ 2025-09-22 16:05 Mira Limbeck
  2025-09-22 17:05 ` [pmg-devel] applied: " Stoiko Ivanov
  0 siblings, 1 reply; 2+ messages in thread
From: Mira Limbeck @ 2025-09-22 16:05 UTC (permalink / raw)
  To: pmg-devel

This fixes the mail lookup based on QID when only time and line info was
available, not a valid QID, which resulted in the following error in the
GUI:
`Error entry 'T68CD4EC2L00000003' not found (500)`

Somewhere between pmg-log-tracker 2.5.0 and 3.0 the behavior of
libc::sscanf seemed to have changed. It now requires mutable access to
the variables passed in, rather than immutable ones.

With 3.0 the behavior changed so that the following was printed:
```
```
Both `time` and `line` were kept at 0, the value they are initialized to
before sscanf is called.

By changing the variables to mutable the values are now parsed and set
correctly.

Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
---
 src/main.rs | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/main.rs b/src/main.rs
index 0a4f192..0299be5 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1964,12 +1964,19 @@ impl Parser {
         };
 
         while let Some(q) = args.opt_value_from_str::<_, String>(["-q", "--queue-id"])? {
-            let ltime: time_t = 0;
-            let rel_line_nr: libc::c_ulong = 0;
+            let mut ltime: time_t = 0;
+            let mut rel_line_nr: libc::c_ulong = 0;
             let input = CString::new(q.as_str())?;
             let bytes = concat!("T%08lXL%08lX", "\0");
             let format = unsafe { std::ffi::CStr::from_bytes_with_nul_unchecked(bytes.as_bytes()) };
-            if unsafe { libc::sscanf(input.as_ptr(), format.as_ptr(), &ltime, &rel_line_nr) == 2 } {
+            if unsafe {
+                libc::sscanf(
+                    input.as_ptr(),
+                    format.as_ptr(),
+                    &mut ltime,
+                    &mut rel_line_nr,
+                ) == 2
+            } {
                 self.options
                     .match_list
                     .push(Match::RelLineNr(ltime, rel_line_nr));
-- 
2.47.3


_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* [pmg-devel] applied: [PATCH pmg-log-tracker] fix wrong QID argument handling
  2025-09-22 16:05 [pmg-devel] [PATCH pmg-log-tracker] fix wrong QID argument handling Mira Limbeck
@ 2025-09-22 17:05 ` Stoiko Ivanov
  0 siblings, 0 replies; 2+ messages in thread
From: Stoiko Ivanov @ 2025-09-22 17:05 UTC (permalink / raw)
  To: Mira Limbeck; +Cc: pmg-devel

Thanks for checking this out and providing the patch!
verified it indeed fixes the observed issue (after reproducing it with the
current version)

Could you maybe add some regression-tests for this - seems quite easy to
attain and would help catching similar issues in the future?

If not let me know - and I'll try to add them.


On Mon, 22 Sep 2025 18:05:14 +0200
Mira Limbeck <m.limbeck@proxmox.com> wrote:

> This fixes the mail lookup based on QID when only time and line info was
> available, not a valid QID, which resulted in the following error in the
> GUI:
> `Error entry 'T68CD4EC2L00000003' not found (500)`
> 
> Somewhere between pmg-log-tracker 2.5.0 and 3.0 the behavior of
> libc::sscanf seemed to have changed. It now requires mutable access to
> the variables passed in, rather than immutable ones.
> 
> With 3.0 the behavior changed so that the following was printed:
> ```
> ```
> Both `time` and `line` were kept at 0, the value they are initialized to
> before sscanf is called.
> 
> By changing the variables to mutable the values are now parsed and set
> correctly.
> 
> Signed-off-by: Mira Limbeck <m.limbeck@proxmox.com>
> ---
>  src/main.rs | 13 ++++++++++---
>  1 file changed, 10 insertions(+), 3 deletions(-)
> 
> diff --git a/src/main.rs b/src/main.rs
> index 0a4f192..0299be5 100644
> --- a/src/main.rs
> +++ b/src/main.rs
> @@ -1964,12 +1964,19 @@ impl Parser {
>          };
>  
>          while let Some(q) = args.opt_value_from_str::<_, String>(["-q", "--queue-id"])? {
> -            let ltime: time_t = 0;
> -            let rel_line_nr: libc::c_ulong = 0;
> +            let mut ltime: time_t = 0;
> +            let mut rel_line_nr: libc::c_ulong = 0;
>              let input = CString::new(q.as_str())?;
>              let bytes = concat!("T%08lXL%08lX", "\0");
>              let format = unsafe { std::ffi::CStr::from_bytes_with_nul_unchecked(bytes.as_bytes()) };
> -            if unsafe { libc::sscanf(input.as_ptr(), format.as_ptr(), &ltime, &rel_line_nr) == 2 } {
> +            if unsafe {
> +                libc::sscanf(
> +                    input.as_ptr(),
> +                    format.as_ptr(),
> +                    &mut ltime,
> +                    &mut rel_line_nr,
> +                ) == 2
> +            } {
>                  self.options
>                      .match_list
>                      .push(Match::RelLineNr(ltime, rel_line_nr));



_______________________________________________
pmg-devel mailing list
pmg-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pmg-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-22 17:05 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-09-22 16:05 [pmg-devel] [PATCH pmg-log-tracker] fix wrong QID argument handling Mira Limbeck
2025-09-22 17:05 ` [pmg-devel] applied: " Stoiko Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal