#563 getvolbypath returns incorrect volume

None
closed
nobody
None
1
2014-05-21
2014-05-19
mmac
No

getvolbypath returns incorrect volume if 2 volumes in the config have paths such that one is prefix of the other. Example config:

[user1]
path = /mnt/vol1/home/user1
[user10]
path = /mnt/vol1/home/user10

This is because of incorrect use of strncmp. See attached patch.

Related

Bugs: #563

Discussion

  • Ralph Böhme
    Ralph Böhme
    2014-05-20

    Hey! Where is the patch?

     
    • mmac
      mmac
      2014-05-20

      It is attached to the ticket and also to this e-mail. It is trivial, just use strcmp instead of strncmp. BTW, I’ve not checked other instances of strncmp use in netatalk. They may have similar problem. Doing strncmp(s1, s2, strlen(s1)) == 0 is almost always wrong, unless the goal is to check that s1 is substring of s2.

      On May 20, 2014, at 09:15 , Ralph Böhme slowfranklin@users.sf.net wrote:

      Hey! Where is the patch?

      [bugs:#563] getvolbypath returns incorrect volume

      Status: open
      Group:
      Created: Mon May 19, 2014 06:54 AM UTC by mmac
      Last Updated: Mon May 19, 2014 06:54 AM UTC
      Owner: nobody

      getvolbypath returns incorrect volume if 2 volumes in the config have paths such that one is prefix of the other. Example config:

      [user1]
      path = /mnt/vol1/home/user1
      [user10]
      path = /mnt/vol1/home/user10

      This is because of incorrect use of strncmp. See attached patch.

      Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/netatalk/bugs/563/

      To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

      Martin
      

      [PGP Key Id: F3F409C4]

       

      Related

      Bugs: #563

      • Ralph Böhme
        Ralph Böhme
        2014-05-20

        There is still no patch attached to this ticket. Please visit the ticket in your favorite browser and see yourself. Looks like you're replying by mail to the SF bugtracker and that strips your attachments or similar.

         
        • mmac
          mmac
          2014-05-20

          On May 20, 2014, at 10:13 , Ralph Böhme slowfranklin@users.sf.net wrote:

          There is still no patch attached to this ticket. Please visit the ticket in your favorite browser and see yourself. Looks like you're replying by mail to the SF bugtracker and that strips your attachments or similar.

          No, I’ve attached the patch as a file to the ticket at the time I’ve created it in my favorite browser. It showed correctly (as an attachment) in the preview. Dunno what sourceforge did with it. I’ve pasted it as text now. Maybe sourceforge won’t delete/ignore it this time.

          [bugs:#563] getvolbypath returns incorrect volume

          Status: open
          Group:
          Created: Mon May 19, 2014 06:54 AM UTC by mmac
          Last Updated: Tue May 20, 2014 04:15 PM UTC
          Owner: nobody

          getvolbypath returns incorrect volume if 2 volumes in the config have paths such that one is prefix of the other. Example config:

          [user1]
          path = /mnt/vol1/home/user1
          [user10]
          path = /mnt/vol1/home/user10

          This is because of incorrect use of strncmp. See attached patch.

          Sent from sourceforge.net because you indicated interest in https://sourceforge.net/p/netatalk/bugs/563/

          To unsubscribe from further messages, please visit https://sourceforge.net/auth/subscriptions/

          Martin
          

          [PGP Key Id: F3F409C4]

           

          Related

          Bugs: #563

  • mmac
    mmac
    2014-05-20

    The trivial patch looks like this:

    --- libatalk/util/netatalk_conf.c.orig  2014-05-18 23:23:19.000000000 -0700
    +++ libatalk/util/netatalk_conf.c   2014-05-18 23:23:57.000000000 -0700
    @@ -1592,7 +1592,7 @@
    
         for (tmp = Volumes; tmp; tmp = tmp->v_next) { /* (1) */
    -        if (strncmp(path, tmp->v_path, strlen(tmp->v_path)) == 0) {
    +        if (strcmp(path, tmp->v_path) == 0) {
                 vol = tmp;
                 goto EC_CLEANUP;
             }
    
     
  • Ralph Böhme
    Ralph Böhme
    2014-05-21

    • status: open --> closed
    • Group: -->